So i purposely put a file in the cv2.VideoCapture() that doesn't exist in my computer to test the try-catch system i've put into my code but for some reason it still gives off the same error it gives when i didn't put a try-catch into my code. how do i fix this??
code:
import numpy as np
import cv2
try:
cap = cv2.VideoCapture('trial.mkv')
while (cap.isOpened()):
ret, frame = cap.read()
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
except:
print("no file found")
error:
[ERROR:0] global C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-cff9bdsm\opencv\modules\videoio\src\cap.cpp (142) cv::VideoCapture::open VIDEOIO(CV_IMAGES): raised OpenCV exception:
OpenCV(4.4.0) C:\Users\appveyor\AppData\Local\Temp\1\pip-req-build-cff9bdsm\opencv\modules\videoio\src\cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): trial.mkv in function 'cv::icvExtractPattern'