Ask Your Question
2

How to set camera resolution (webcam) with opencv?

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

norzanbzura gravatar image

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

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
5

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

Witek gravatar image

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

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 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

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

Seen: 80,126 times

Last updated: Jun 02 '14