How can I adjust the brightness of a video. cap.set(cv2.CAP_PROP_BRIGHTNESS) isn't working

I am fairly new to using OpenCV and on a tutorial, I was shown that you can adjust the brightness of either your webcam or a video by using cap.set(). However, whenever I try setting the values for brightness nothing seems to get happening, and when I use cap.get() to get the brightness value, it always ends up returning 0. What can I do to fix this issue?

import cv2

videoCapture = cv2.VideoCapture(0)

#Set Brightness
videoCapture.set(cv2.CAP_PROP_BRIGHTNESS, 1000) #Nothing is changed.

current_brightness = videoCapture.get(cv2.CAP_PROP_BRIGHTNESS)
print(current_brightness) #This doesn't work, it keeps returning 0, which isn't suppose to happen.

while True:
    canPlay, vidFrame = videoCapture.read()

    cv2.imshow("Video", vidFrame)

    if cv2.waitKey(1) == ord('q'):
        break

please check the return value here.

then, only a small subset of all properties will be supported by your combo of hw / os / driver / backend.

try another backend, CAP_DSHOW, CAP_MSMF, etc.

and please, DO check return values like canPlay or videoCapture.isOpened()

1 Like