In OpenCV, you can set the exposure for your camera manually by using the VideoCapture::set method. What isn’t obvious is what value to pass in for it. I have experimented with various webcams and the below settings seem to be accurate enough. Not all cameras allow setting the exposure programatically, so if the code below doesn’t work, you might try a different camera, or experiment with different values. Once you’ve set a value manually, I haven’t found a way to switch back to auto-exposure without restarting the camera.
Below is an example of using this setting in Python
import cv2 cap = cv2.VideoCapture(0) cap.set(cv2.CAP_PROP_EXPOSURE,-4) while(True): ret, frame = cap.read() cv2.imshow('frame',frame) if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() cv2.destroyAllWindows()
Estimated exposure settings from Joan Charmant’s ‘Review of the ELP-USBFHD01M camera’