September 13th, 2010, 09:18 AM
#1
Camera input - OpenCV
Hi folks,
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:
Code:
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include "cvcam.h"
#include "cv.h"
#include "highgui.h"
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");
return -1;
}
cvNamedWindow( "in", 0 );
for(;;)
{
if(!cvGrabFrame(capture))
break;
frame = cvRetrieveFrame(capture);
cvShowImage("in", frame );
if( cvWaitKey(10) >= 0 )
break;
}
cvReleaseCapture( &capture );
cvDestroyWindow("in");
return 0;
}
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.
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.
September 14th, 2010, 09:29 AM
#2
Re: Camera input - OpenCV
Nobody? Nor even to tell me how to use the webcam without OpenCV?
Tags for this Thread
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width
Bookmarks