So I have been trying to get OpenCV to work. I displayed some pictures in windows and simple stuff like that. Then, following along in my book, I attempted to write a program which would take video from a webcam and place it in a video. Here is my code:
#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
main( int argc, char** argv ){
cvNamedWindow( "Webcam", CV_WINDOW_AUTOSIZE );
CvCapture* capture;
if( argc==1 ){
capture = cvCreateCameraCapture(0);
}else{
capture = cvCreateFileCapture( -1 );(I believe that this -1 is the source of the problem. I am not sure why becuase it is simply supposed to choose a webcam but it is the only part of the code underlined in red)
}
assert( capture != NULL );
IplImage* frame;
while(1){
frame = cvQueryFrame( capture );
if( !frame ) break;
cvShowImage( "Webcam", frame );
char c = cvWaitKey(33);
if( c == 27 ) break;
}
cvReleaseCapture( &capture );
cvDestroyWindow( "Webcam" );
return 0;
}
By the way, I am working in C++. So when I build this it finds one error. I can not figure out what it is so I was wondering if I could have some assistance. Thanks-Magykguy
As I edited in the post above, I think the -1 is the problem. I tryed replacing your bit of code with mine and it still said it has 1 error when I built it. Like I said, I think this 1 error is the -1.