Ask Your Question

Turning off auto gain and exposure.

asked 2012-08-19 07:40:18 -0500

Marduk gravatar image

updated 2017-12-30 14:31:02 -0500

Hi, what im trying to do is to turn off auto gain and auto exposure of my camera (Sony PS Eye). I know it is possible because i can do it in driver. However when want to do this from my code using following methods:

CvCapture* cap = cvCaptureFromCAM(0);    
cvSetCaptureProperty(cap, CV_CAP_PROP_EXPOSURE, 0.0);
cvSetCaptureProperty(cap, CV_CAP_PROP_GAIN, 0.0);

nothing happens, first cvSetCaptureProperty function is returning string "Error" to console and second one "setVideoSettings - QueryInterface Error". Am i doing something wrong?

Please help me, thanks.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2018-09-05 02:03:53 -0500

ak1 gravatar image

updated 2018-09-12 06:15:01 -0500

First disable auto exposure mode and then manually set the exposure to the desired value. you can use this following snippet for your purpose

VideoCapture cap(id);
Mat src;
struct v4l2_control ctrl;; = V4L2_CID_EXPOSURE_AUTO;
ctrl.value = V4L2_EXPOSURE_MANUAL;
if(v4l2_ioctl(descriptor, VIDIOC_S_CTRL, &ctrl))
    std::cout << "Error disabling auto exposure\n"; = V4L2_CID_EXPOSURE_ABSOLUTE;
ctrl.value = 100;
if(v4l2_ioctl(descriptor, VIDIOC_S_CTRL, &ctrl))
    std::cout << "Error setting exposure\n";
edit flag offensive delete link more
Login/Signup to Answer

Question Tools


Asked: 2012-08-19 07:40:18 -0500

Seen: 3,609 times

Last updated: Sep 12 '18