Setting VideoCapture resolution fails

asked 2016-03-09 05:18:38 -0500

iko79 gravatar image

Hi,

I'm trying to set VideoCapture resolution as follows, but it doesn't seem to do anything. The camera does support the requested format. I also tried different resolutions. No matter what I do, my VideoCapture is created with VGA resolution. Also, some other settings I'm trying to query do not seem to be supported.

VideoCapture *capture = new VideoCapture(0);

if( !capture->set( CAP_PROP_FRAME_WIDTH, 1920 ) || !capture->set( CAP_PROP_FRAME_HEIGHT, 1080 ) )
{
    //not print - both set calls return 'true'
    cerr << "setting resolution to full HD failed!" << std::endl;
}

double fps = capture->get( CAP_PROP_POS_FRAMES );
int width = capture->get( CAP_PROP_FRAME_WIDTH ); // returns 640
int height = capture->get( CAP_PROP_FRAME_HEIGHT ); // returns 480
int format = capture->get( CAP_PROP_FORMAT );

I remember those things never worked for me in the past, I'm wondering if this is implemented at all or if I'm making a mistake. OS: Windows 8.1, camera: MS LifeCam Studio, OpenCV: 3.1

Thanks, iko

edit retag flag offensive close merge delete

Comments

it's very likely, that your camera-driver just does not support this resolution (or only for still-images)

berak gravatar imageberak ( 2016-03-09 05:22:58 -0500 )edit

It does support Full HD, I tried with AMCap, VLC, and also with my DirectShow code - no problems whatsoever. So you're saying, this works for you? I'm asking because I can't remember a single time I succeeded in doing this, also with other cameras, so I thought this is not properly supported in OpenCV, just as enumerating cameras. But I was still using the old C interface until recently, so I thought that's the reason.

iko79 gravatar imageiko79 ( 2016-03-10 04:22:42 -0500 )edit

I have had this problem also, as a workaround read the frames, then resize them.

amannababanana gravatar imageamannababanana ( 2016-03-23 17:27:49 -0500 )edit

Am I understanding you correctly that you suggest to capture 640x480 and then resize to Full HD?

iko79 gravatar imageiko79 ( 2017-02-17 06:00:59 -0500 )edit