opencv-cvCaptureFromCAM(CV_CAP_DSHOW)捕获空白帧 [英] opencv - cvCaptureFromCAM(CV_CAP_DSHOW) capture blank frame

查看:1122
本文介绍了opencv-cvCaptureFromCAM(CV_CAP_DSHOW)捕获空白帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows中使用OpenCV 2.1和Visual Studio 2008.我正在尝试从CCD相机中抓取帧并希望在Windows上显示.相机为PAL格式.相机正在检测,但显示黑屏.

I am using OpenCV 2.1 and Visual Studio 2008 in Windows. I am trying to grab the frames from CCD camera and want to display on Windows. Camera is with PAL format. Camera is detecting but showing the blank grey screen.

我发现许多与黑屏有关的帖子,但在我的情况下没有人在工作.所以发布我发布这个问题.

I found many post related to blank screen but no one is work in my case. So post I post this question.

下面是我的代码:

#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,但空白屏幕.

Above code return frame size 320 X 240 but blank screen.

对于代码为CvCapture* capture = cvCaptureFromCAM(1);

我在板上使用Avermedia金相机卡.那么,我需要使用SDK才能使用此相机吗?或者可以使用CCD相机吗?

I am using Avermedia Gold Camera Card on my board. So Do I need SDK to use this camera or is there any option to use CCD camera??

驱动程序已正确安装,并与EzCaptureVC应用程序一起检查.

Driver is installed correctly and check with EzCaptureVC application.

推荐答案

OpenCV需要支持您的相机,否则无法保证它能正常工作:检查

OpenCV needs to support your camera else there's no guarantee its going to work: check the compatibility list.

2.1也很过时了.我建议您再试一次2.3.1,因为这方面已有一些改进.

Also 2.1 it's very outdated. I suggest you try again with the 2.3.1 since there has been some improvements in this area.

这篇关于opencv-cvCaptureFromCAM(CV_CAP_DSHOW)捕获空白帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆