From 6eb34716b81596d2a6ae69cd18a70c4507cbc293 Mon Sep 17 00:00:00 2001 From: Hashem Zavvari Date: Tue, 18 Oct 2022 11:43:08 +0330 Subject: [PATCH] Merge pull request #22635 from hzawary:4.x Setting CAP_PROP_AUTO_EXPOSURE on VideoCapture with backend DSHOW does not change anything. Now with this implementation the property can be used with value 1 for availability. --- modules/videoio/src/cap_dshow.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/videoio/src/cap_dshow.cpp b/modules/videoio/src/cap_dshow.cpp index db42601dab..3d7013d48f 100644 --- a/modules/videoio/src/cap_dshow.cpp +++ b/modules/videoio/src/cap_dshow.cpp @@ -3474,6 +3474,18 @@ bool VideoCapture_DShow::setProperty(int propIdx, double propVal) return g_VI.isDeviceSetup(m_index); } + case CV_CAP_PROP_AUTO_EXPOSURE: + { + // Flags are required to toggle auto exposure or not, but the setProperty interface does not support multiple parameters + bool enabled = cvRound(propVal) == 1; + long minExposure, maxExposure, delta, currentExposure, flags, defaultValue; + if (!g_VI.getVideoSettingCamera(m_index, CameraControl_Exposure, minExposure, maxExposure, delta, currentExposure, flags, defaultValue)) + { + return false; + } + return g_VI.setVideoSettingCamera(m_index, CameraControl_Exposure, currentExposure, enabled ? CameraControl_Flags_Auto | CameraControl_Flags_Manual : CameraControl_Flags_Manual, enabled ? true : false); + } + case CV_CAP_PROP_AUTOFOCUS: { // Flags are required to toggle autofocus or not, but the setProperty interface does not support multiple parameters