0

I'm learning OpenCV because I want to build and program a 3D Scanner over the summer.

I bought three webcams for this purpose (two for the actual stereo images and one for texture [or as a backup]).

I tried to get a webcam's video with OpenCV. However, this does not work, as I ended up with a black screen, instead of video.

I then tried the same code with my grandmother's webcam. It worked fine. However, I already bought 3 webcams of the type that I was planning on using to build my scanner: http://www.amazon.com/Webcam-Camera-Vision-Meeting-compatible/dp/B0015TJNEY/ref=pd_bxgy_e_img_b

I don't want to buy any new webcams.

Does anybody have any idea of why my webcams don't work with OpenCV (they work with other programs)?

How can I get OpenCV to accept my webcams?

Any suggestions would be appreciated!

Thanks

eboix
  • 5,113
  • 1
  • 27
  • 38
  • @shobhit Well, I looked for any error messages - none. I also looked at the driver file. It's called: `usbvideo.sys`. I also looked around Stackoverflow and found: http://stackoverflow.com/questions/4430367/opencv-webcam-capture-problem?rq=1. It basically states my problem. But the first solution doesn't work because I had already included the `cvWaitKey`. The second solution seems to be my problem, but I want to know how to fix it. – eboix Jun 16 '12 at 18:37
  • What is your operating system? We can tell it is windows by the usbvideo.sys driver file but even so. Is the camera working with other programs? – Rui Marques Jun 17 '12 at 12:24
  • The camera works with other programs, such as VLC player. I have Windows 7 Enterprise. If I can't get my webcam to work with OpenCV, then I'll download some other library and get the webcam input into a file, which I will then read with OpenCV. – eboix Jun 17 '12 at 16:51

1 Answers1

0

If your program pass this step , you should try a different number for cvCaptureFromCAM(0); 0 is the first web cam but maybe your's is set as 1, 2 or 3. you can also try -1 and see what happens

CvCapture *capture;
capture = cvCaptureFromCAM(0);
if (!capture)
{
    printf("Error at capture");
    return 1;
}
Mark
  • 1,100
  • 9
  • 17
  • Thanks for your help. I did this before. `capture` wasn't `NULL`. The image I got from it wasn't `NULL` either. However, it was blank. – eboix Jun 16 '12 at 19:40
  • Try using cvWaitKey(1); after each frame or try with debug, and see if the waiting is the problem. – Mark Jun 16 '12 at 19:50
  • My code actually has `cvWaitKey`, and it works with my grandmother's camera. – eboix Jun 16 '12 at 20:07
  • Take a look at this post http://stackoverflow.com/questions/2601194/displaying-webcam-feed-using-opencv-and-python but basically is suggesting what i was saying – Mark Jun 16 '12 at 20:48