0

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.

Below is my code:

#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;
}

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

Code is working fine for usb webcam with code CvCapture* capture = cvCaptureFromCAM(1);

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??

Driver is installed correctly and check with EzCaptureVC application.

Sergio
  • 28,539
  • 11
  • 85
  • 132
user934179
  • 21
  • 2
  • 4

1 Answers1

2

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

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.

karlphillip
  • 92,053
  • 36
  • 243
  • 426
  • Thanks for quick reply karlphillip. I check the camera compatibility list and my camera is not in that list. So I am going to use opencv 2.3.1 and I will let us know my result with that But let me add some more information regarding result I faced before. My current code specified in question was working fine before some days with different camera capture card. I change the camera capture card for higher feature and I lost the feed from camera. – user934179 May 04 '12 at 03:28
  • Ok, so that confirms that the problem is with the **camera & opencv**, and not with your code & opencv. – karlphillip May 04 '12 at 03:40
  • Now I change the mode of video capture. I try to use videoInput to capture from camera and it is working... BUT one problem arised is, I am not able to change the video size in videoInput. It is showing in 320X280 default size And I need it in 640X480 size. Any help ??????? – user934179 May 04 '12 at 13:28
  • Yes, but you may not like it: [Increasing camera capture resolution in OpenCV](http://stackoverflow.com/questions/14287/increasing-camera-capture-resolution-in-opencv). The easiest way is to set the new size with `cvSetCaptureProperty()`, but if that doesn't work you should read the rest of the posts. – karlphillip May 04 '12 at 13:42