Ask Your Question

WebCam won't open since 2.4.6

asked 2013-07-07 07:25:15 -0600

pheips gravatar image

updated 2018-11-06 12:05:06 -0600


I'm using VideoCapture to connect to my webcam in the following manner since OpenCV2.4.4:

cv::VideoCapture vcap;
cv::Mat image;
      vcap >> image;

and never had any problems. Since version 2.4.6 though, opening my cam fails and isOpened() always returns false. When I downgrade to 2.4.5 it works again. Also loading a video with 2.4.6 works, so the reason seems to be the combination of 2.4.6 and my webcam. I also tried to open the cam with the constructor. cv::VideoCapture vcap(CV_CAP_ANY); There is also no other camera connected, so CV_CAP_ANY should work as it did with version 2.4.5

I'm using Kubuntu 12.04 and Logitech C270 USB HD Webcam. The camera worked by plug & play, so i guess some standard drivers are used. If someone can explain me how, I would check which driver is used ;)

I'm gratefull for any tipps or suggestions.

edit retag flag offensive close merge delete

6 answers

Sort by ยป oldest newest most voted

answered 2013-07-09 07:15:46 -0600

I'm sorry, it is my fault. V4L2 and V4L are guarded by invalid defines. I create a ticket and pull request. It will be fixed in 2.4 in some hours.

edit flag offensive delete link more


is it applicable to master branch also? I have same problem in master branch. It was working fine a few days ago. Yesterday, it is not.

Abid Rahman K gravatar imageAbid Rahman K ( 2013-07-12 23:00:41 -0600 )edit

All fixes from 2.4 are merged to master every week. So this problem must be fixed in master too.

Alexander Smorkalov gravatar imageAlexander Smorkalov ( 2013-08-19 03:29:46 -0600 )edit

Yeah... I found it was working fine after a couple of days.. thank you.

Abid Rahman K gravatar imageAbid Rahman K ( 2013-08-19 05:06:02 -0600 )edit

answered 2013-07-08 02:21:55 -0600

Same problem with my laptop camera. I am using ubuntu 13.04 and my laptop's embedded camera (uvcvideo: Found UVC 1.00 device HP Truevision HD (0bda:58d8). I have also tried a Logitech UVC camera but doesn't work either.

I haven't tried OpenCV 2.4.5 in Ubuntu but with Debian I had my camera working with OpenCV 2.4.5

I tried the smiledetect example but doesn't work.

edit flag offensive delete link more



Please report this as bug.

SR gravatar imageSR ( 2013-07-08 05:35:57 -0600 )edit

answered 2013-07-08 10:12:29 -0600

Me too. It blocked at "cv >> frame;".

edit flag offensive delete link more


My original problem ist different. The cam doesn't block at cv>>frame, but can't even be opened. Nevertheless I tried to rebuild Opencv 2.4.6 yesterday with different options. None of them did fix my problem, but at one point I also got a connection to my camera (the light of my webcam was green), but I then experienced the same problem as you did: grabbing simply blocked anything alse.

I found out, that in my case the reason for a blocking camera was, that I built the OpenCV 2.4.6 with UNICAP. Once I built it without Unicap I got my initial problem again.

So maybe your cam will work fine, if you rebuild your opencv without Unicap (and maybe without TBB, as I heard that this may cause blockings too).

pheips gravatar imagepheips ( 2013-07-08 12:16:08 -0600 )edit

answered 2013-07-30 14:36:40 -0600

Bismarky gravatar image

The Windows version of OpenCV 2.4.6 also has the same problem. Capture from webcam doesn't work.

edit flag offensive delete link more

answered 2013-07-08 05:05:42 -0600

the_phet gravatar image

Same problem, my code has been working for a year and now it is not working anymore.

import cv, cv2

vc = cv2.VideoCapture(1)
vc.set(cv.CV_CAP_PROP_FRAME_WIDTH, 640)
vc.set(cv.CV_CAP_PROP_FRAME_HEIGHT, 480)

    ret,frame =
    #print len(frame)
    key =  cv2.waitKey(30)

This code was always working, now I get:

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /build/opencv/src/opencv-2.4.6/modules/highgui/src/window.cpp, line 269
Traceback (most recent call last):
  File "", line 10, in <module>
cv2.error: /build/opencv/src/opencv-2.4.6/modules/highgui/src/window.cpp:269: error: (-215) size.width>0 && size.height>0 in function imshow
edit flag offensive delete link more


I had the same exact problem using OpenCV and python 2.7.4 Edit: managed to fix this by rebuilding openCV with WITH_V4L=ON

spudfkc gravatar imagespudfkc ( 2013-07-13 11:20:20 -0600 )edit

"Assertion failed (size.width>0 && size.height>0) in imshow" is caused by "frame" the vc read return "None",so "imshow" can't show a window whose size is (0,0). Add "print frame"in your loops ,you will get it

jacklondon gravatar imagejacklondon ( 2013-08-17 22:10:30 -0600 )edit

answered 2013-08-17 22:05:26 -0600

i meet it too.and i find the reason.the camera can't open in its first time.And you can use loops to open it .you may find it return false first time and return True after that. Hope that can help you

edit flag offensive delete link more

Question Tools



Asked: 2013-07-07 07:25:15 -0600

Seen: 11,529 times

Last updated: Aug 17 '13