【发布时间】:2012-05-13 00:36:07
【问题描述】:
我在 Windows 中使用 OpenCV 2.1 和 Visual Studio 2008。我正在尝试从 CCD 相机中获取帧并希望在 Windows 上显示。相机为 PAL 格式。摄像头正在检测,但显示空白灰屏。
我发现了许多与空白屏幕相关的帖子,但没有一个适合我的情况。所以发布我发布这个问题。
下面是我的代码:
#include "stdafx.h"
#include "cv.h"
#include "cxcore.h"
#include "highgui.h"
#include <iostream>
int main(int argc, char* argv[])
{
cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );
CvCapture* capture = cvCaptureFromCAM(CV_CAP_DSHOW);
if ( !capture ) {
fprintf( stderr, "ERROR: capture is NULL \n" );
getchar();
return -1;
}
while ( 1 ) {
IplImage* frame = cvQueryFrame( capture );
if ( !frame ) {
fprintf( stderr, "ERROR: frame is null...\n" );
getchar();
break;
}
else
{
fprintf( stderr, "Size of camera frame %d X %d\n",frame->width,frame->height );
}
cvShowImage( "mywindow", frame );
if ( (cvWaitKey(10) & 255) == 27 ) break;
}
// Release the capture device housekeeping
cvReleaseCapture( &capture );
cvDestroyWindow("mywindow");
return 0;
}
以上代码返回帧大小 320 X 240 但空白屏幕。
使用代码 CvCapture* capture = cvCaptureFromCAM(1); 的 USB 网络摄像头代码运行良好
我在我的板上使用 Avermedia Gold 相机卡。那么我需要SDK来使用这个摄像头还是有任何选项可以使用CCD摄像头??
驱动程序已正确安装并检查 EzCaptureVC 应用程序。
【问题讨论】: