Home > other >  Opencv USB camera operation failure
Opencv USB camera operation failure

Time:02-16

Environment:
Python 3.7.1
OpenCV rule 3.4.3

Question phenomenon:
Run the following code
 
The import cv2
The import numpy

Cap=cv2. VideoCapture (' Z - Arm 2140. Avi) # adjustable parameters read or video call camera
While (cap) isOpened ()) :
Ret, frame=cap. The read ()
Cv2. Imshow (" cap ", frame)
If cv2. WaitKey (1) & amp; 0 XFF==word (' q ') :
Break

Cap. Release ()
Cv2. DestroyAllWindows ()


Can run normally about ten seconds, then the following error message:
>
RESTART: C: \ Users \ \ Administrator \ \ AppData \ Local \ designed \ Python Python37 \ opencv test1. Py
Traceback (the most recent call last) :
The File "C: \ Users \ \ Administrator \ AppData \ Local \ designed \ Python \ Python37 \ opencv test1. Py", line 879, in & lt; module>
Cv2. Imshow (" cap ", frame)
cv2. Error: OpenCV (rule 3.4.3) C: \ \ projects \ OpenCV - python OpenCV \ modules \ highgui \ SRC \ Windows CPP: 356: error: (- 215: an Assertion failed) size. Width> 0 & amp; & Size. Height> 0 in function 'CV: : imshow'
>

Try methods:
1, whether open USB camera to obtain images directly, or directly from a video image, is a phenomenon,
2, step through found cap. IsOpened (), the return value is normal, but the cap. The read () will be NULL, cause the program error,
3, try in the cap. The read () will be NULL, to open the video images, also not line, cap. The read () or there will be a NULL



CodePudding user response:

Would you to solve this problem? I also encountered this problem
  • Related