Ask Your Question
2

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
6

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");

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

edit flag offensive delete link more

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 ( 2014-10-20 10:22:37 -0600 )edit

Question Tools

Stats

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

Seen: 126,555 times

Last updated: Jun 02 '14