OpenCV darken oversaturated webcam image
Question: I have a (fairly cheap) webcam which produces images which are far lighter
than it should be. The camera does have brightness correction - the
adjustments are obvious when moving from light to dark - but it is
consistently far to bright.

I am looking for a way to reduce the brightness without iterating over the
entire frame (OpenCV Python bindings on a Raspberry Pi). Does that exist? Or
better, is there a standard way of sending hints to a webcam to reduce the
brightness?

    
    
    import cv2
    
    # create video capture
    cap = cv2.VideoCapture(0)
    window = cv2.namedWindow("output", 1)
    
    while True:
    
        # read the frames
        _,frame = cap.read()
        cv2.imshow("output",frame)
    
        if cv2.waitKey(33)== 27:
            break
    
    # Clean up everything before leaving
    cv2.destroyAllWindows()
    cap.release()
    


Answer: I forgot Raspberry Pi is just running a regular OS. What an awesome machine.
Thanks for the code which confirms that you just have a regular cv2 image.

Simple vectorized scaling (without playing with each pixel) should be simple.
Below just scales every pixel. It would be easy to add a few lines to
normalize the image if it has a major offset.

    
    
    import numpy
    #...
    scale = 0.5  # whatever scale you want
    frame_darker = (frame * scale).astype(numpy.uint8)
    #...
    

Does that look like the start of what you want?

