Ask Your Question

cv2.VideoCapture(1) is causing errors. Please help me fix this.

asked 2017-08-01 16:00:09 -0500

tj gravatar image

this is the error: OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /build/opencv-SviWsf/opencv-, line 3737 Traceback (most recent call last): File "", line 157, in <module> gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) cv2.error: /build/opencv-SviWsf/opencv- error: (-215) scn == 3 || scn == 4 in function cvtColor

Also how do I know what to enter in the device id in videocapture().?


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-08-02 08:58:07 -0500

Raki gravatar image

updated 2017-08-02 08:59:42 -0500

A wild guess: Is your capturing device actually capturing frames in the first place? Could you check it with:

VideoCapture cap(0); // open the default camera
if(!cap.isOpened())  // check if we succeeded
     cout<< "Something is wrong, I am not receiving anything!"<<endl;

More can be found here.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-08-01 16:00:09 -0500

Seen: 440 times

Last updated: Aug 02 '17