Set frame resolution problem

asked 2015-03-23 18:57:53 -0600

Marcvs gravatar image

I know this is a trivial question, but I really don't know why I can't change the acquiring resolution of my webcam. Even if I set the CV_CAP_PROP_FRAME_WIDTH and CV_CAP_PROP_FRAME_WIDTH properties with an arbitrary (but valid) value, the resolution still remains 640x480. My code is:

#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>

#pragma comment(lib, "opencv_core249d.lib")
#pragma comment(lib, "opencv_highgui249d.lib")

using namespace cv;

int main()
{
    VideoCapture video(0);
    video.set(CV_CAP_PROP_FRAME_WIDTH, 1280); // <==
    video.set(CV_CAP_PROP_FRAME_HEIGHT, 800); // <==

    Mat frame;

    while (!(waitKey(1)%255 == 27))
    {
        video.read(frame);
        imshow("VideoCapture", frame);
    }

    return EXIT_SUCCESS;
}

I foud a solution that uses the function resize, but I'm sure this is not the solution to my problem.

Is there something that I don't know about OpenCV 2.4.9 (I worked without any problem with a previous version of OpenCV)? How can I resolve this problem?

Thank you.

OS: Windows 8.1 - IDE: Visual Studio 2013 - OpenCV version: 2.4.9 - Webcam: Microsoft HD 6000

edit retag flag offensive close merge delete

Comments

Try using Amcap and see whether you are able to switch resolution with that application. If that works, then resolution switching should work with OpenCV as well. Link to download http://amcap-webcam-capture.en.lo4d.com/

Spark gravatar imageSpark ( 2015-03-24 03:39:24 -0600 )edit

@Spark Thanks. I tried the software that you suggested me and I was able to change the resolution of my webcam (I also tried with the HP TrueVision HD camera of my laptop and all worked fine). But the problem with the OpenCV code still remains...

edit: I retried my code and I noticed that the problem with the resolution concerns only the Microsoft HD 6000 webcam. How can I verify the compatibility between OpenCV and this particular webcam if its name is not in this list?

Marcvs gravatar imageMarcvs ( 2015-03-24 05:19:08 -0600 )edit