Ask Your Question

Revision history [back]

Set frame resolution problem

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