opencv: Setting CAP_PROP_EXPOSURE on VideoCapture does not change anything
System information (version)
- OpenCV => 3.3.0
- Operating System / Platform => Windows 10 Enterprise 64 Bit
- Compiler => using opencv-python
Detailed description
Setting exposure is not working with the python wrapper for opencv, I don’t know if this is related to the wrapper.
I tried to set CAP_PROP_AUTO_EXPOSURE as well to disable any auto exposure.
The camera is a HD USB Camera USB8MP02G http://www.elpcctv.com/8mp-highdefinition-usb-camera-module-usb20-sony-imx179-color-cmos-sensor-75degree-lens-p-223.html
Steps to reproduce
I use this snippet to try to set the exposure to different values
import cv2
cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_AUTO_EXPOSURE, 0)
cap.set(cv2.CAP_PROP_EXPOSURE, -7.0)
print(cap.get(cv2.CAP_PROP_EXPOSURE))
while True:
ret, frame = cap.read()
cv2.imshow('test', frame)
cv2.waitKey(1)
I can’t see any difference when changing exposure
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 24 (1 by maintainers)
i think finally i found a solution, at least for my problem,
i have to first set the auto_exposure to 3 (auto mode)
then i have to set it to 1 (manual mode)
and then i can set the manual exposure
you can set the settings with shell too
list available options
set them with python
I’ve been having almost exactly the same problem using an ELP camera. I solved it by doing
cap.set(cv2.CAP_PROP_AUTO_EXPOSURE, 0.25)
Then setting the exposure to what I needed. I believe that 0.25 is the value that CAP_PROP_AUTO_EXPOSURE needs to be to give you manual control.
I needed to set my exposure as an absolute value, 0.01 in my case, rather than using negative values. But that may be different for your camera.
I hope this helps!
I have encountered an issue with cap prop exposure for my specific camera, the logitech c270 webcam
So the problem is that when you set cap prop exposure the first time the camera is placed in, the exposure is not changed, but if you close the python code and rerun it, it works. Whenever you take the camera out and put it in again and run the code again, the exposure not being set property arises again.
To fix this issue call ret, frame = cap.read() before the cap exposure call
I believe the reason for calling read before setting the exposure for it to work is because the camera needs to adjust and understand what it is seeing before adjusting the exposure, sort of like dipping your toes in a cold pool.
I may be completely wrong with my explanation, but I hope this helps anyone 😃
I find the reason!! At first, I use OpenCV 3.4.10. I follows the code
output
I can not set the
CV_CAP_PROP_EXPOSURE
orCV_CAP_PROP_AUTO_EXPOSURE
.However, when I change the python version to 4.2.0 at the first line
output is
Yes ! ! I can set the
CV_CAP_PROP_EXPOSURE
. I try form1
to30
, the EXPOSURE will increase.In my case, it works on Windows, but doesn’t work on Mac. Is there anyone who could set CAP_PROP_EXPOSURE and CAP_PROP_AUTO_EXPOSURE properties on Mac?
Hi. I could make the camera work on manual mode now with auto exposure set on 0.25. But I can’t put the Camera back on auto mode. I have tried setting 0 and 1 as the auto_exposure value, but no help. Can you please guide?
This really work for my problem when I try to set focus value manually. Tks u so much!!!
Usage questions should go to Users OpenCV Q/A forum: http://answers.opencv.org This tracker is for issues and bugs that needs fix in OpenCV.
Always check returned values.
Properties availability/implementation/etc are backend-specific. So it is bad idea to use them without backend check. To use V4L2 properties you should force backend via
CAP_V4L2
parameter.Check
cv.getBuildInformation()
at first for V4L2 availability:I believe it should be fixed in fresh OpenCV packages.
Hi hoerin, The auto_exposure property should expect two values 0.75 as auto exposure On and 0.25 as auto exposure OFF. Once you set auto exposure Off with 0.25 then set exposure to any value that you desire. This is tested on Mac and Raspberry both.