Schnozzle Berry
Schnozzle Berry

Reputation: 31

See3CAM / OpenCV Auto White Balance Support

I'm trying to set the white balance setting of the See3Cam_CU130 webcam to a single value via python. This is to prevent the white balance from changing during my analysis and interfering with the results. I figured the best way to do this would be to:

  1. Set the camera to auto white balance
  2. Read what the current white balance temperature is while it's on auto
  3. Disable the auto white balance, and leave it fixed at the previous value

To do this I've tried running:

cam = cv2.VideoCapture(0)
currentWB = cam.get(cv2.CAP_PROP_WHITE_BALANCE_BLUE_U)
cam.set(cv2.CAP_PROP_WHITE_BALANCE_BLUE_U, currentWB)

Although the last line returns True, the white balance parameter remains on auto, with its value unchanged.

If I instead run this code with my C920 webcam, the white balance becomes turned off as anticipated and I'm able to get/set its value correctly.

Is this an issue with the See3Cam, or does OpenCV just have better support for the C920 as it's a more popular webcam? Is there anything that I can do to get the desired behavior?

I understand that I could open a dshow config dialog with cam.set(cv2.CAP_PROP_SETTINGS, 1) but I'd rather not do this manually, for obvious reasons.

This was tested on Windows 10, Python 3.5.2, OpenCV 3.2.0

Upvotes: 1

Views: 4154

Answers (2)

Anna Svagzdys
Anna Svagzdys

Reputation: 63

cv2.CAP_PROP_WHITE_BALANCE_BLUE_U is unsupported in OpenCV 3.2 (https://docs.opencv.org/3.2.0/d4/d15/group__videoio__flags__base.html), and also the C130 does not have the ability to set the balance for the color channels individually. The best you will be able to do is adjust the white balance temperature, which I think is cv2.CAP_PROP_TEMPERATURE in OpenCV.

If you are in Linux, install v4l2-utils to test these settings from the command line for easier debugging/testing. Running v4l2-ctl --device=/your/cam/address -L will list the available controls and their settings for the camera (this will also tell you whether the values you set in through OpenCV have actually been applied). You can experiment to find a good white balance temperature by setting v4l2-ctl --device=/your/cam/address -c white_balance_temperature_auto=0 to enable manual control and then trying different values, e.g. v4l2-ctl --device=/your/cam/address -c white_balance_temperature=3500

Upvotes: 0

White balance manual control doesn't get updated when in auto mode according to UVC spec. So there is no point in reading manual value when the control is in auto mode.

Upvotes: 0

Related Questions