Stop undesired cropping of Webcam capture images OpenCV

asked 2013-08-08 17:50:35 -0500

Troy A gravatar image

updated 2013-08-09 11:57:44 -0500

Hi All,

I'm using OpenCV 2.4.6. and I'm trying to stream images from two Genius Wide Angle webcams.

Using the Image Acquisition Toolbox in Matlab, I'm able to capture images that have a much wider FOV than what I'm capturing in OpenCV. Adjusting the image resolution of the capture doesn't seem to affect this.

Is there any way to stop the image boundaries from being cropped?

Thanks!

CvCapture* capture = 0;
capture = cvCaptureFromCAM(0);

if(!capture)
{
    printf("Could not initialize capturing...\n");
    return -1;
}
cvNamedWindow("video");
while(true)
{
    IplImage* frame = 0;
    frame = cvQueryFrame(capture);
    if(!frame)
        break;
    cvShowImage("video", frame);
    int c = cvWaitKey(20);
    if((char)c==27 )
        break;
}
    cvReleaseCapture(&capture);
    return 0;
}

EDIT - Newer OpenCV calls yield the same result. Here's a more correct version.

 // Initialize left and right capture devices
    VideoCapture capture_left, capture_right;
    capture_left.open(LEFT_INDEX);
    capture_right.open(RIGHT_INDEX);

    if ( !capture_left.isOpened() ) {
        fprintf( stderr, "ERROR: left camera init problem \n" );
        getchar();
        return -1;
    }
    if ( !capture_right.isOpened() ) {
        fprintf( stderr, "ERROR: right camera init problem \n" );
        getchar();
        return -1;
    }
    // Create windows in which the captured images will be presented
    namedWindow( "Left Image", CV_WINDOW_AUTOSIZE );
    namedWindow( "Right Image", CV_WINDOW_AUTOSIZE );

    // Show the image captured from the camera in the window and repeat
    while ( 1 ) {

        // Get one frame from each
        capture_left >> left_frame;
        capture_right >> right_frame;

        if ( left_frame.empty() ) {
            fprintf( stderr, "ERROR: left frame is null...\n" );
            getchar();
            break;
        }
        if ( right_frame.empty() ) {
            fprintf( stderr, "ERROR: right frame is null...\n" );
            getchar();
            break;
        }
        imshow( "Left Image", left_frame );
        imshow( "Right Image", right_frame );

        if ( (cvWaitKey(10) & 255) == 27 ) break;

    }
    return 0;
}
edit retag flag offensive close merge delete

Comments

If you are using openCV 2.4.6, is there any reason why you are still using the openCV 1.x C - style directives? Try switching everything towards the correct C++ OpenCV 2.X API and see if your problem is solved.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-08-09 03:50:59 -0500 )edit
1

Sorry Steve, I've tried both to see if it helps. Should have posted the newer version; I've edited the question to include new and old.

Troy A gravatar imageTroy A ( 2013-08-09 11:59:36 -0500 )edit