September 13th, 2010, 09:18 AM
Camera input - OpenCV
I want to display the video being captured by the webcam in C++. I've found this code, that uses OpenCV and it's very simple:
However, I don't know why it fails (in the "if (!capture)", it always enters - capture is null), and I don't know how to fix it.
int main( int argc, char** argv )
IplImage* frame = 0;
CvCapture* capture = 0;
capture = cvCaptureFromCAM(1);
frame = cvQueryFrame( capture );
if( !capture )
fprintf(stderr,"Could not initialize capturing...\n");
cvNamedWindow( "in", 0 );
frame = cvRetrieveFrame(capture);
cvShowImage("in", frame );
if( cvWaitKey(10) >= 0 )
cvReleaseCapture( &capture );
I don't know if there is anyone here that could help me with that OpenCV issue. However, if there isn't, if you tell me another way to grab the camera input (and display it in a window) would be great!
I'm using Windows XP, if that matters.
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!