Not all parameters are supported by all cameras - actually, they are one of the most troublesome part of the OpenCV library. Each camera type - from android cameras to USB cameras to professional ones offer a different interface to modify its parameters. There are many branches in OpenCV code to support as many of them, but of course not all possibilities are covered.

What you can do is to investigate your camera driver, write a patch for OpenCV and send it to code.opencv.org. This way others will enjoy your work, the same way you enjoy others'.

There is also a possibility that your camera does not support your request - most USB cams are cheap and simple. Maybe that parameter is just not available for modifications.

If you are sure the camera supports a given param (you say the camera manufacturer provides some code) and do not want to mess with OpenCV, you can wrap that sample code in C++ with boost::python, to make it available in Python. Then, enjoy using it.

Answer from Sam on Stack Overflow
🌐
Principiaprogramatica
principiaprogramatica.com › 2017 › 06 › 11 › setting-manual-exposure-in-opencv
Setting Manual Exposure in OpenCV – Principia Programatica: Greg Miller's Blog
June 11, 2017 - 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’
🌐
Stack Overflow
stackoverflow.com › questions › 70243485 › changing-cap-prop-exposure-through-user-input-with-opencv
python - Changing CAP_PROP_EXPOSURE through user input with openCV - Stack Overflow
import cv2 # Connect to IMX291 (1) captureDevice = cv2.VideoCapture(1, cv2.CAP_DSHOW) # Loop through every frame until we close our webcam key2 = cv2.waitKey(0) # Exposure exposure = 0 captureDevice.set(cv2.CAP_PROP_EXPOSURE,exposure) # Gain captureDevice.set(cv2.CAP_PROP_GAIN,1) # Window Resolution captureDevice.set(cv2.CAP_PROP_FRAME_WIDTH, 480) captureDevice.set(cv2.CAP_PROP_FRAME_HEIGHT, 480) while captureDevice.isOpened(): ret, frame = captureDevice.read() # Show image cv2.imshow('Webcam', frame) # Checks whether q has been hit and stops the loop key = cv2.waitKey(0) if key == ord('q'): break captureDevice.set(cv2.CAP_PROP_EXPOSURE,exposure) if key2 == ord('e'): exposure += 0.5 if key2 == ord('d'): exposure -= 0.5 # Releases the webcam captureDevice.release() # Closes the frame cv2.destroyAllWindows()
🌐
GitHub
github.com › opencv › opencv › issues › 9738
Setting CAP_PROP_EXPOSURE on VideoCapture does not change anything · Issue #9738 · opencv/opencv · GitHub
September 28, 2017 - 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)
Author: opencv
🌐
OpenCV Q&A Forum
answers.opencv.org › question › 96137 › is-there-any-range-of-values-for-the-exposure-flag
Is there any range of values for the exposure flag? - OpenCV Q&A Forum
June 10, 2016 - The CAP_PROP_EXPOSURE isn't generally supported. You can check OpenCV yourself looking at the setProperty method for any API implementation here (Check the files cap_*.cpp).
🌐
Jancy Standard Library
vovkos.github.io › doxyrest-showcase › opencv › sphinx_rtd_theme › enum_cv_VideoCaptureProperties.html
enum cv::VideoCaptureProperties — OpenCV Documentation
#include <videoio.hpp> enum VideoCaptureProperties { CAP_PROP_POS_MSEC =0, CAP_PROP_POS_FRAMES =1, CAP_PROP_POS_AVI_RATIO =2, CAP_PROP_FRAME_WIDTH =3, CAP_PROP_FRAME_HEIGHT =4, CAP_PROP_FPS =5, CAP_PROP_FOURCC =6, CAP_PROP_FRAME_COUNT =7, CAP_PROP_FORMAT =8, CAP_PROP_MODE =9, CAP_PROP_BRIGHTNESS =10, CAP_PROP_CONTRAST =11, CAP_PROP_SATURATION =12, CAP_PROP_HUE =13, CAP_PROP_GAIN =14, CAP_PROP_EXPOSURE =15, CAP_PROP_CONVERT_RGB =16, CAP_PROP_WHITE_BALANCE_BLUE_U =17, CAP_PROP_RECTIFICATION =18, CAP_PROP_MONOCHROME =19, CAP_PROP_SHARPNESS =20, CAP_PROP_AUTO_EXPOSURE =21, CAP_PROP_GAMMA =22, CAP_
🌐
TechOverflow
techoverflow.net › 2022 › 11 › 01 › list-of-all-cv2-cap_prop_-properties-for-opencv-in-python
List of all cv2.CAP_PROP_... properties for OpenCV in Python | TechOverflow
October 31, 2022 - cv2.CAP_PROP_APERTURE cv2.CAP_PROP_ARAVIS_AUTOTRIGGER cv2.CAP_PROP_AUTOFOCUS cv2.CAP_PROP_AUTO_EXPOSURE cv2.CAP_PROP_AUTO_WB cv2.CAP_PROP_BACKEND cv2.CAP_PROP_BACKLIGHT cv2.CAP_PROP_BITRATE cv2.CAP_PROP_BRIGHTNESS cv2.CAP_PROP_BUFFERSIZE cv2.CAP_PROP_CHANNEL cv2.CAP_PROP_CODEC_PIXEL_FORMAT cv2.CAP_PROP_CONTRAST cv2.CAP_PROP_CONVERT_RGB cv2.CAP_PROP_DC1394_MAX cv2.CAP_PROP_DC1394_MODE_AUTO cv2.CAP_PROP_DC1394_MODE_MANUAL cv2.CAP_PROP_DC1394_MODE_ONE_PUSH_AUTO cv2.CAP_PROP_DC1394_OFF cv2.CAP_PROP_EXPOSURE cv2.CAP_PROP_EXPOSUREPROGRAM cv2.CAP_PROP_FOCUS cv2.CAP_PROP_FORMAT cv2.CAP_PROP_FOURCC cv2
🌐
OpenCV Q&A Forum
answers.opencv.org › question › 233617 › cv2cap_prop_exposure-is-different-in-ubuntu-and-windows-and-what-is-the-meaning-of-each-the-value-of-cv2cap_prop_exposure
cv2.CAP_PROP_EXPOSURE is different in ubuntu and windows, and what is the meaning of each the value of cv2.CAP_PROP_EXPOSURE ? - OpenCV Q&A Forum
I was working my project with one webcam in both windows10 and ubuntu 16.04, and I find when I get this webcam's exposure bycap.get(cv2.CAP_PROP_EXPOSURE), I will get a negative integer (around -5 to -7) in windows10, and a positive integer (around 70) in ubuntu 16.04, I want to know why there is difference? and what is the meaning of value of cv2.CAP_PROP_EXPOSURE in windows10 and ubuntu 16.04 is respectively? In both operating system, I have my python environment as follow:
Find elsewhere
🌐
Pseudoaj
pseudoaj.com › 2014 › 12 › pseudoajcode2-python-opencv-adjusting.html
PseudoAJ: PseudoAjCode#2 Python OpenCV Adjusting Camera Parameters
#Camera Parameteres camera_port = 0 ramp_frames = 30 #Getting the camera references cam_l = cv2.VideoCapture(1) cam_r = cv2.VideoCapture(2) #Camera Settings gain=174 cam_l.set(cv2.cv.CV_CAP_PROP_GAIN,gain) cam_r.set(cv2.cv.CV_CAP_PROP_GAIN,gain) brightness=50 cam_l.set(cv2.cv.CV_CAP_PROP_BRIGHTNESS,brightness) cam_r.set(cv2.cv.CV_CAP_PROP_BRIGHTNESS,brightness) contrast=67 cam_l.set(cv2.cv.CV_CAP_PROP_CONTRAST,contrast) cam_r.set(cv2.cv.CV_CAP_PROP_CONTRAST,contrast) saturation=85 cam_l.set(cv2.cv.CV_CAP_PROP_SATURATION,saturation) cam_r.set(cv2.cv.CV_CAP_PROP_SATURATION,saturation) exposure=-9 cam_l.set(cv2.cv.CV_CAP_PROP_EXPOSURE,exposure) cam_r.set(cv2.cv.CV_CAP_PROP_EXPOSURE,exposure)
🌐
sqlpey
sqlpey.com › python › top-5-methods-to-set-camera-parameters-in-opencv-with-python
Top 5 Methods to Set Camera Parameters in OpenCV with Python …
November 23, 2024 - 3. CAP_PROP_FRAME_WIDTH Width of the frames in the video stream. 4. CAP_PROP_FRAME_HEIGHT Height of the frames in the video stream. 10. CAP_PROP_BRIGHTNESS Brightness of the image. 12. CAP_PROP_SATURATION Saturation of the image. 15. CAP_PROP_EXPOSURE Exposure of the camera.
Top answer
1 of 2
18

There is a method available to change properties of VideoCapture object in OpenCV which can be used to set exposure of input image.

cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_EXPOSURE, 40) 

However this parameter is not supported by all cameras. Each camera type offers a different interface to set its parameters. There are many branches in OpenCV code to support as many of them, but of course not all the possibilities are covered.

Same is the case with my camera. So I had to find a different solution. That is using v4l2_ctl utility from command line terminal.

v4l2-ctl -d /dev/video0 -c exposure_absolute=40

But this retains its value for current video session only. That means you have to start video preview first and then set this property As soon as VideoCapture is released, the exposure value is restored to default.

I wanted to control exposure within my python script, so I used subprocess module to run linux bash command. e.g.

import subprocess
subprocess.check_call("v4l2-ctl -d /dev/video0 -c exposure_absolute=40",shell=True)
2 of 2
1

For instance

I was trying with a c920 for a while whithout success, but sometimes worked, other not using this:

cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_EXPOSURE, -4) 
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 240) # after not change the exposure

But finally I realized that I was setting the width and height just after, and so I change the order and now is working fine!! Don´t blow your mind trying to disable the CAP_PROP_AUTO_EXPOSURE flag!! Its not necessary(at least with c920 on windows)!!

cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 240) # before works fine
cap.set(cv2.CAP_PROP_EXPOSURE, -4) 

By the way, the range of exposure in C920 is from -2 to -11!!(on windows 10)

Thanks a lot

🌐
OpenCV
docs.opencv.org › 3.4.20 › d4 › d15 › group__videoio__flags__base.html
OpenCV: Flags for video I/O
Select preferred API for a capture object. To be used in the VideoCapture::VideoCapture() constructor or VideoCapture::open() ... Backends are available only if they have been built with your OpenCV binaries. See Video I/O with OpenCV Overview for more information. ... Generic camera output modes identifier. ... Currently, these are supported through the libv4l backend only. ... VideoCapture generic properties identifier.
🌐
MakeHardware
makehardware.com › 2016 › 06 › 21 › manual-exposure-vs-auto-exposure-for-elp-2-mp-usb-camera
Manual Exposure vs Auto Exposure for ELP 2 MP USB Camera — MakeHardware
February 25, 2026 - It took me some time to discover that depending on the version of OpenCV you are using, the property’s name might actually be CAP_PROP_EXPOSURE.
🌐
Stack Overflow
stackoverflow.com › questions › 42220509 › right-name-for-python-opencv-video-capture-exposure-setting
image - Right name for Python OpenCV video capture exposure setting - Stack Overflow
March 7, 2017 - I am using OpenCV 3.1.0 and Python 3.5.2 to capture some images with different exposure time with cv2.VideoCapture, like this: cap = cv2.VideoCapture(0) k = -4 cap_next = cap.set(15, k) ret, img = cap.read() outcam = './img.jpg' cv2.imwrite(outcam, img) cap.release() However, I managed to access to the exposure video attribute only through its number, and not with its name string: when I substitute 15 with CAP_PROP_EXPOSURE or CV_CAP_PROP_EXPOSURE I get the error NameError: name 'CAP_PROP_EXPOSURE' is not defined.
🌐
GitHub
github.com › opencv › opencv › issues › 17019
CAP_PROP_AUTO_EXPOSURE not working with DSHOW backend · Issue #17019 · opencv/opencv · GitHub
April 8, 2020 - import cv2 _capture = cv2.VideoCapture(0, cv2.CAP_DSHOW) _ret, img = _capture.read() # turn the autoexposure off print(_capture.set(cv2.CAP_PROP_EXPOSURE, -7)) # works # print(_capture.set(cv2.CAP_PROP_EXPOSURE, 1)) # didn't work print(_capture.set(cv2.CAP_PROP_AUTO_EXPOSURE, 0.75)) # didn't work _ret = True while _ret: _ret, img = _capture.read() key_code = cv2.waitKey(1) if (key_code == 27) or (key_code == ord('q')): break cv2.imshow('img', img)
Author: opencv
🌐
GitHub
gist.github.com › anujonthemove › e879ef6e2bd3f0ee1743c4c48ef779c1
A handy list of VideoCapture object parameters taken from official OpenCV docs. · GitHub
""" # List of properties to demonstrate properties = { "CAP_PROP_POS_MSEC": cv2.CAP_PROP_POS_MSEC, "CAP_PROP_POS_FRAMES": cv2.CAP_PROP_POS_FRAMES, "CAP_PROP_POS_AVI_RATIO": cv2.CAP_PROP_POS_AVI_RATIO, "CAP_PROP_FRAME_WIDTH": cv2.CAP_PROP_FRAME_WIDTH, "CAP_PROP_FRAME_HEIGHT": cv2.CAP_PROP_FRAME_HEIGHT, "CAP_PROP_FPS": cv2.CAP_PROP_FPS, "CAP_PROP_FOURCC": cv2.CAP_PROP_FOURCC, "CAP_PROP_FRAME_COUNT": cv2.CAP_PROP_FRAME_COUNT, "CAP_PROP_BRIGHTNESS": cv2.CAP_PROP_BRIGHTNESS, "CAP_PROP_CONTRAST": cv2.CAP_PROP_CONTRAST, "CAP_PROP_SATURATION": cv2.CAP_PROP_SATURATION, "CAP_PROP_HUE": cv2.CAP_PROP_HUE,
🌐
DNMTechs
dnmtechs.com › camera-parameter-configuration-in-opencv-with-python-3
Camera Parameter Configuration in OpenCV with Python 3 – DNMTechs – Sharing and Storing Technology Knowledge
Similarly, CAP_PROP_FPS is used to set the frame rate. After configuring the camera parameters, we enter a loop to continuously read frames from the camera using the read method. The frames are then displayed using imshow. Pressing ‘q’ will break the loop and release the camera using release. Besides resolution and frame rate, OpenCV allows us to configure other camera parameters as well. For example, to set the exposure time, we can use the cv2.CAP_PROP_EXPOSURE property:
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › programming › python
Pi Camera exposure control using OpenCV - Raspberry Pi Forums
February 14, 2021 - It seems like auto exposure is turning on and off. But when I try to set the value manually using cv2.CAP_PROP_EXPOSURE = -1 to -13 (according to some online blogs) the camera is not responding. The same goes for other flags. Most of them do not seem to be responding at all.