7

I'm trying to learn OpenCV. I have been playing around with it for an entire day trying to get it to recognize my camera. I just can't get it to work and I can't find any information about it.

My camera is a usb xbox live webcam, as soon as I connected it to my computer windows recognized it as if it were its own child and installed the drivers.

DISCLAIMER I'm like completely clueless as I have never worked with cameras before in code and I don't know how hard or difficult it would be to use one, nor do I know where to start, what information to look up, or anything like that. :( DISCLAIMER

I found this example on the opencv website at this url: http://opencv.willowgarage.com/wiki/CameraCapture

I copy and pasted the first one which says "Here is a simple framework to connect to a camera and show the images in a Window.". I formatted it correctly and got it to compile and run perfectly, but it gives the error "ERROR: capture is NULL" when I execute it(not a compiler error, its an error in the application)

Alex
  • 241
  • 2
  • 3
  • 4
  • Can [VirtualDub](http://www.virtualdub.org/) capture from your camera? – genpfault Dec 20 '10 at 01:25
  • Not sure if I did it right, but one VirtualDub I went to File->Capture AVI and when it asked for video device I picked my camera. The littel light on the camera turned on, but the preview on the program just shows a black box – Alex Dec 20 '10 at 14:25

2 Answers2

4

I think there are more than enough code on stackoverflow that shows how to do the trick:

OpenCV 2.1: Runtime error

Unable to detect web cam in OpenCV

OpenCV: process every frame

OpenCV 'cvQueryFrame' non-blocking on OS X?

Community
  • 1
  • 1
karlphillip
  • 92,053
  • 36
  • 243
  • 426
-2

as your given link :

 #include "cv.h" 
 #include "highgui.h"  

try this one

#include <"opencv\cv.h> 
#include <"opencv\highgui.h> //"opencv is the file where cv.h and highgui placed
p.s.w.g
  • 146,324
  • 30
  • 291
  • 331