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
Using Python 32 Bit in 64Bit Platform
What Are Python Pandas Equivalents for R Functions Like Str(), Summary(), and Head()
Running Python Script as a Systemd Service
How to Benchmark Part of Tensorflow Graph
Python Not Displaying Executable Output Properly
Python Parsing Log File to Extract Events in Real Time
How to Get the Process Name by Pid in Linux Using Python
List All Currently Open File Handles
Matplotlib-Animation "No Moviewriters Available"
Does R Have Function Startswith or Endswith Like Python
Python Memory Debugging with Gdb
Using && in Subprocess.Popen for Command Chaining
How to Download a Single File from Gitlab
How to Downgrade My Version of Python from 3.7.5 to 3.6.5 on Ubuntu