cvQueryFrame always return NULL
sorry for my poor English,but I meet a annoying problem.I use a laptop with win 8.1 system and opencv 3.0. I wrote a small program hoping to show the video captured from the built-in camera, but failed. I figured out that the problem lies in the function cvQueryFrame(), as it always return NULL but the camera is opened. the code is as follow:
int main()
{
CvCapture* capture=cvCaptureFromCAM(-1);
if(capture==NULL)
{
printf("camera not available");
return 0;
}
cvNamedWindow("video",1);
char c = cvWaitKey(1000);
IplImage* frame=cvQueryFrame(capture);
for (;;)
{
frame=cvQueryFrame(capture);
if(!frame)
break;
cvShowImage("video",frame);
if(cvWaitKey(100)>=0)
break;
}
cvReleaseCapture(&capture);
cvDestroyWindow("video");
return 0;
}
please, you must not use the c-api .
try this
oh thank you,it works,but why?would you please give me some hints or reference?