Ask Your Question
5

WebCam won't open since 2.4.6

asked Jul 7 '13

pheips gravatar image

updated Nov 6 '18

Hi,

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

cv::VideoCapture vcap;
cv::Mat image;
...
vcap.open(CV_CAP_ANY);
if(vcap.isOpened()){
    while(m_runGrabber){
      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.

Preview: (hide)

6 answers

Sort by » oldest newest most voted
10

answered Jul 9 '13

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.

Preview: (hide)

Comments

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 (Jul 13 '13)edit

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

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

Abid Rahman K gravatar imageAbid Rahman K (Aug 19 '13)edit
1

answered Jul 8 '13

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.

Preview: (hide)

Comments

1

Please report this as bug.

SR gravatar imageSR (Jul 8 '13)edit
1

answered Jul 8 '13

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

Preview: (hide)

Comments

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 (Jul 8 '13)edit
0

answered Jul 30 '13

Bismarky gravatar image

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

Preview: (hide)
0

answered Jul 8 '13

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)
cv2.namedWindow("video")
vc.set(cv.CV_CAP_PROP_FRAME_WIDTH, 640)
vc.set(cv.CV_CAP_PROP_FRAME_HEIGHT, 480)

while(1):
    ret,frame = vc.read()
    cv2.imshow("video",frame)
    #print len(frame)
    key =  cv2.waitKey(30)

This code was always working, now I get:

python2 play_cam.py 
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 "play_cam.py", line 10, in <module>
    cv2.imshow("video",frame)
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
Preview: (hide)

Comments

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

spudfkc gravatar imagespudfkc (Jul 13 '13)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 (Aug 18 '13)edit
0

answered Aug 18 '13

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

Preview: (hide)

Question Tools

2 followers

Stats

Asked: Jul 7 '13

Seen: 11,823 times

Last updated: Aug 17 '13