cvSetCaptureProperty() always fixes the aspect ratio to 4:3 in DirectShow

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

cvSetCaptureProperty() always fixes the aspect ratio to 4:3 in DirectShow

Minh-Tri Pham
Hi OpenCV's developers,

Since OpenCV 1.1's pre-release, DirectShow has been used instead of the
good old VideoForWindows library to interface with video capture devices
in Windows. That is a big improvement in capturing speed. Thank you and
Theo Watson for this very useful contribution. However, the video
resolution is always fixed to 4:3 when function cvSetCapturePropery() is
called. Tracing back from the source code in both OpenCV's pre-built
release and the latest CVS revision of OpenCV, I have found that it was
preset whenever the the function is called, as shown below.

File: cvcap_dshow.cpp, revision 1.2
bool CvCaptureCAM_DShow::setProperty( int property_id, double value )
{
    int width = 0, height = 0;

    switch( property_id )
    {
    case CV_CAP_PROP_FRAME_WIDTH:
        width = cvRound(value);
        height = width*3/4;
        break;
    case CV_CAP_PROP_FRAME_HEIGHT:
        height = cvRound(value);
        width = height*4/3;
    default:
        return false;
    }

    if( width != VI.getWidth(index) || height != VI.getHeight(index) )
    {
        VI.stopDevice(index);
        VI.setupDevice(index, width, height);
    }
    return VI.isDeviceSetup(index);
}


I have a webcam which does support aspect ratios other than 4:3. Is it
possible that this presetting be removed in the upcoming OpenCV's release?

Thank you and best regards,

Minh-Tri

--
Minh-Tri Pham
Ph.D. Candidate and Research Associate
Nanyang Technological University, Singapore
http://mtpham.sharkdolphin.com