Cannot control exposure/white balance on OV5648 USB camera with Python OpenCV DSHOW/MSMF Windows 10

Hi, I have a 5MP OV5648 USB camera module (SKU B0454) on Windows 10, Python 3.10.4 and OpenCV 4.5.5.64. I’m trying to control the basic camera settings from Python/OpenCV, mainly exposure and white balance, but I can’t fully control them. Depending on whether I use the DSHOW or MSMF backend, some settings work and others don’t, and it’s inconsistent. For example, with one backend I can set exposure but not white balance, and with the other it’s the opposite. Has anyone managed to get both exposure and white balance working through OpenCV on this module?

Thanks for the details. We tested the same module here and white balance can be set through OpenCV on it, so it’s not a hard limitation of the camera. Before we go further, can you check the camera in Amcap.exe? Open it, toggle auto white balance off, then try moving the WB slider and see whether the image actually changes. If the slider works there, the camera itself is fine and we need to look at the OpenCV side. I’ve sent you a reference video link by PM showing those Amcap steps.

I tried the Amcap method. Turning auto WB off and using the slider does work there, so the hardware side seems okay. Could you share the OpenCV script you used for white balance? I’ve tried the usual CAP_PROP_* values before, but only some settings succeed and some don’t. I have screenshots from my earlier attempts if that helps.

I’ve sent you a small demo script (arducam_demo.py) by private message. Please connect the camera, run it, and let me know whether it changes the white balance / auto WB behavior. It’s basically a minimal config test for the camera.

I ran arducam_demo.py, but I still can’t set auto white balance or adjust WB from the script. Same result as before. Which Python and OpenCV versions are you testing with? I’m also starting to wonder if my unit is a different revision than the one you tested.

I’ve sent you a screenshot by PM with the Python and OpenCV versions we’re using. About the module: the current listings only show UB0233, not B0454, so there may be a version mismatch. Can you check the SKU printed on the packaging box and confirm whether it says B0454 or UB0233? That would explain why some settings behave differently.

Checked the box, and it’s actually UB0233, not B0454. Sorry for the confusion. After updating to the OpenCV version you recommended, the original white balance issue seems resolved now. I can toggle auto WB and adjust the slider from my script. Thanks.

Great, glad that’s working now. Feel free to reach out if anything else comes up.

So white balance is working now, but I’ve hit a new problem. Exposure and white balance seem to interfere with each other. When I change one, the other changes or resets, and I can’t get a stable exposure setting. Is there a way to keep them independent? Also, do you have a demo for disabling auto exposure and setting a specific exposure value?

From our side, exposure and white balance should be two independent settings and shouldn’t affect each other. We don’t have a specific demo for enabling/disabling auto exposure and inputting an exposure value. To dig into this, can you record a short video showing the interference? For example, change white balance and show exposure shifting. That will help us reproduce the issue.

I can get a video tomorrow. In the meantime, I’m also seeing that CAP_PROP_AUTO_EXPOSURE doesn’t behave correctly with the DSHOW backend. Setting it to 0 or 1 doesn’t always stick, or the image doesn’t change as expected. Is there a recommended method to set auto exposure with this camera, or is MSMF better for exposure?

To sum up where we are: your white balance issue is fixed after the OpenCV update, and the remaining open item is the exposure/white balance interference, which we still need a video of. We don’t have a ready-made demo for auto exposure on/off plus setting an exposure value. For the DSHOW CAP_PROP_AUTO_EXPOSURE problem, try the MSMF backend as a workaround, since DSHOW auto exposure control is often limited on these modules. Send the video when you can and we’ll go from there.