raspberrypi / picamera2

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

AttributeError: 'dict' object has no attribute 'AeExposureModeEnum' #1119

Closed Gordon999 closed 1 month ago

Gordon999 commented 2 months ago

Describe the bug Using https://github.com/raspberrypi/picamera2/blob/main/examples/hailo/detect.py and trying to send controls to the camera. It fails as shown below

To Reproduce from libcamera import controls picam2.set_controls({"AeEnable": True,"AeExposureMode": controls.AeExposureModeEnum.Normal}) AttributeError: 'dict' object has no attribute 'AeExposureModeEnum'

Expected behaviour I expect the camera to switch Mode

Console Output, Screenshots picam2.set_controls({"AeEnable": True,"AeExposureMode": controls.AeExposureModeEnum.Normal}) AttributeError: 'dict' object has no attribute 'AeExposureModeEnum'

hardware: Pi5, hailo, pi v3 camera

davidplowman commented 1 month ago

I wonder if you've reused controls as a variable, pointing to a dictionary object? (Yes, I've done that!)

So maybe

import libcamera
...
picam2.set_controls({"AeEnable": True,"AeExposureMode": libcamera.controls.AeExposureModeEnum.Normal})
Gordon999 commented 1 month ago

Excellent, thankyou.

The picamera2 hailo example I based my code on uses..

controls = {'FrameRate': 30} config = picam2.create_preview_configuration(main, lores=lores, controls=controls)

so I have renamed 'controls' and my code now works

Gordon999 commented 1 month ago

Solved