Ask Your Question

Revision history [back]

I know this is a very old post, but just in case other stumble upon it, let me offer the solution I used. First of all, I'm using OpenCV 2.4.11. At least in that version, the CV_CAP_PROP_AUTO_EXPOSURE is not implemented. However, it turns out that the logic that handles setting CV_CAP_PROP_EXPOSURE (at least the DirectShow-based interface used for Windows) already has the hooks necessary to restore the default values for the exposure setting.

The code is found the opencv\sources\modules\highgui\src\cap_dshow.cpp in the videoInput::setVideoSettingCamera function. I added the following code as a quick and dirty solution for restoring auto-exposure functionality:

if ( (Property == CameraControl_Exposure) && (lValue == 0.0) ) useDefaultValue = true;

Then rebuild the highgui library and use the modified copy. This allows you to restore the auto-exposure using cap.set(CV_CAP_PROP_EXPOSURE, 0.0) in your code. Of course, really you ought to implement CV_CAP_PROP_AUTO_EXPOSURE for a proper solution, but this has worked well for my purposes.

Hope this helps someone.