raspberrypi / picamera2

New libcamera based python library
BSD 2-Clause "Simplified" License
895 stars 189 forks source link

[BUG] AwbMode not working #803

Open matmicro opened 1 year ago

matmicro commented 1 year ago

How to change the AwbMode ? Current code does not works :

camera.set_controls({"AwbMode", 3})

Error is :

Traceback (most recent call last):
:File "/home/test.py", line 449, in <module>
:     InitCamera()
:   File "/home/test.py", line 136, in InitCamera
:     camera.set_controls({"AwbEnable", 1})
:   File "/usr/local/lib/python3.9/dist-packages/picamera2/picamera2.py", line 1093, in set_controls
:     self.controls.set_controls(controls)
:   File "/usr/local/lib/python3.9/dist-packages/picamera2/controls.py", line 64, in set_controls
:     raise RuntimeError(f"Cannot update controls with {type(controls)} type")
: RuntimeError: Cannot update controls with <class 'set'> type

Any idea on what could be the root cause ?

davidplowman commented 1 year ago

Hi, could you perhaps include a little more of your code? For example, the following works for me:

from picamera2 import Picamera2
picam2 = Picamera2()
picam2.start()
picam2.set_controls({'AwbMode': 3})

If you can produce a similar but small standalone example that fails then it would be easier to investigate. Thanks!

liamw9534 commented 3 weeks ago

Just to point out that {"AwbMode", 3} is not a dictionary but a set in python. This should in fact be {"AwbMode": 3} i.e., you must use a colon rather than a comma in the key/value assignment.