显示捕获的视频

时间:2013-01-11 13:15:57

标签: opencv

在opencv2.2 visual c ++ express 2010中,灰色屏幕显示为输出而非实际相机输入。是否因为任何dll文件?

我正在尝试执行一个简单的opencv程序来显示捕获的视频源,但得到一个灰色窗口作为输出。

int main(void) {

CvCapture* capture = cvCaptureFromCAM (CV_CAP_ANY);
if( !capture ) {
    fprintf( stderr, "ERROR: capture is NULL \n");
    getchar();
    return -1;
}
// create a window in which the capture images will be presented
cvNamedWindow("mywindow", CV_WINDOW_AUTOSIZE);
// show the image captured from the camera in the window and repeat
while (1) {
    // get one frame
    IplImage* frame = cvQueryFrame (capture);
    if (!frame) {
        fprintf( stderr, "ERROR: frame is null...\n");
        getchar();
        break;
    }
    cvShowImage("mywindow", frame);
    // do not release the frame

    // terminate
    if ((cvWaitKey(10) & 255) == 27) break;
}

// release the capture device
cvReleaseCapture (&capture);
cvDestroyWindow("mywindow");

return EXIT_SUCCESS;
}

0 个答案:

没有答案