Ask Your Question

sum_of_lilith's profile - activity

2015-11-28 11:11:57 -0600 commented question cvQueryFrame always return NULL

oh thank you,it works,but why?would you please give me some hints or reference?

2015-11-28 07:42:16 -0600 asked a question 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;

}