Ask Your Question
2

How to set camera resolution (webcam) with opencv?

asked Jun 2 '14

norzanbzura gravatar image

updated Jun 2 '14

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.

Preview: (hide)

1 answer

Sort by » oldest newest most voted
6

answered Jun 2 '14

Witek gravatar image

updated Jun 2 '14

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

cap.set(CV_CAP_PROP_FRAME_WIDTH,640);
cap.set(CV_CAP_PROP_FRAME_HEIGHT,480);

http://docs.opencv.org/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-set

Preview: (hide)

Comments

2

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 (Oct 20 '14)edit

Question Tools

Stats

Asked: Jun 2 '14

Seen: 128,252 times

Last updated: Jun 02 '14