Ask Your Question

How to set camera resolution (webcam) with opencv?

asked 2014-06-02 00:17:13 -0600

norzanbzura gravatar image

updated 2014-06-02 01:33:03 -0600

berak gravatar image

I have a problem which I don't know how to create a function to set camera resolution on webcam with openCV. There's anyone can help me? Thank you in advance.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-06-02 01:13:17 -0600

Witek gravatar image

updated 2014-06-02 01:14:12 -0600

cv::VideoCapture cap;
if (!cap.isOpened())  // check if succeeded to connect to the camera
   CV_Assert("Cam open failed");


edit flag offensive delete link more



then if you use OpenCV 3 just replace the last instructions with these:

cap.set(cv::CAP_PROP_FRAME_WIDTH, valueX); // valueX = your wanted width
cap.set(cv::CAP_PROP_FRAME_HEIGHT, valueY); // valueY = your wanted heigth
Doombot gravatar imageDoombot ( 2014-10-20 10:22:37 -0600 )edit

Question Tools


Asked: 2014-06-02 00:17:13 -0600

Seen: 123,363 times

Last updated: Jun 02 '14