Opencv Error on Python

How to catch OpenCV Error in Python

Try cv2.error.

try:
...
except cv2.error as e:
...

Here's the page from the documentation but it's only for the C/C++ interface -- I can't find anything on the Python error handling for OpenCV (I find the documentation for the Python interface to be sadly lacking).

OPENCV error while captureing video from webcam in python

I looks like input is 0x0 picture, thats why i cannot show, if you know your camera resolution try this maybe:

camera=0
cap = cv2.VideoCapture(camera, cv2.CAP_DSHOW)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1050)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920)

while cap.isOpened():
success, image = cap.read()
if not success:
print("Ignoring empty camera frame.")
# If loading a video, use 'break' instead of 'continue'.
continue
cv2.imshow('Image', image)
if cv2.waitKey(5) & 0xFF == ord("q"):
break
cap.release()

good luck



Related Topics



Leave a reply



Submit