I got OpenCV 2.1 installed on my laptop and is trying to implement a face detection program. I'm using Logitech C210 for my project. I know the camera is okay because the software detects and displays it, and starting facedetect.exe in the samples directory shows the camera to be working. But somehow when using the original facedetect.cpp code in my VS2010 Ultimate I couldn't even get the cvCaptureFromCAM to work! Here's my code:
#include "stdafx.h"
#include <iostream>
#include "cv.h"
#include "highgui.h"
using namespace std;
using namespace cv;
int main(int, char**) {
IplImage* frame;
// CvCapture* cap = cvCaptureFromCAM(-1);
// cvNamedWindow( "Example2_9", CV_WINDOW_AUTOSIZE );
CvCapture* capture;
cvWaitKey(20);
capture = cvCreateCameraCapture( -1 ); //yes, if 0 doesn't work try with -1
//assert( capture != NULL );
for(;;) {
frame = cvQueryFrame(capture);
if(frame == NULL)
return -1;
imshow("cap", frame);
if(waitKey(30) >= 0)
break;
}
}
Okay, so that isn't the actual facedetect code(it's too long), but it highlights the problem here it think:
Using breakpoints I found out that the value capture after cvCaptureFromCAM is 0x000000. This isn't supposed to happen, is it? Can someone tell me what's going on?