waveform80 / picamera

A pure Python interface to the Raspberry Pi camera module
https://picamera.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.57k stars 355 forks source link

reading MMAL_PARAMETER_STATISTICS structure raises "invalid Argument" error #677

Open barney-NG opened 3 years ago

barney-NG commented 3 years ago

I want to have a look at the camera statistics. (esp. frame_count and frames_discarded) I tried to dig into the topic and it seems that the picamera implementation looks ok. Maybe someone can commit (Or show me how to read that struct correctly) Thank you in advance Axel

picamera: 1.13

pi@raspberrypi:~ $ ll /lib/modules/5.10.11-v7l+/kernel/drivers/staging/vc04_services/vchiq-mmal/bcm2835-mmal-vchiq.ko
-rw-r--r-- 1 root root 31344 Feb  4 13:36 /lib/modules/5.10.11-v7l+/kernel/drivers/staging/vc04_services/vchiq-mmal/bcm2835-mmal-vchiq.ko

Here's the problem in two lines... === source ===

from picamera import mmal, mmalobj as mo
camera = mo.MMALCamera()

# reading common parameter SYSTEM_TIME -> OK
sys_time = camera.control.params[mmal.MMAL_PARAMETER_SYSTEM_TIME]

# reading common parameter STATISTICS -> KO
stats_buf = camera.control.params[mmal.MMAL_PARAMETER_STATISTICS]

=== error ===

Traceback (most recent call last):
  File "test.py", line 8, in <module>
    stats = camera.control.params[mmal.MMAL_PARAMETER_STATISTICS]
  File "/usr/lib/python3/dist-packages/picamera/mmalobj.py", line 1531, in __getitem__
    prefix="Failed to get parameter %d" % key)
  File "/usr/lib/python3/dist-packages/picamera/exc.py", line 184, in mmal_check
    raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Failed to get parameter 6: Argument is invalid