Ask Your Question

Troy A's profile - activity

2013-08-09 11:59:36 -0500 commented question Stop undesired cropping of Webcam capture images OpenCV

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.

2013-08-09 11:57:44 -0500 received badge  Editor (source)
2013-08-08 17:50:35 -0500 asked a question Stop undesired cropping of Webcam capture images OpenCV

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