User avatar
Posts: 2554
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Enhancing picamera with new MMAL features

Fri May 15, 2020 7:40 pm

MMAL contains a feature that allows to display Figure of Merit in order to ease focusing of camera lens.
That was recently made available to raspiv̶i̶d̶still ("--focus"/"-fw").

I wanted to use that feature with picamera and was able to do so.
The last line in this snippet enables FoM for the camera.

Code: Select all

camera = mo.MMALCamera()
camera.outputs[0].framesize = (500, 500)
camera.outputs[0].framerate = 30

camera.control.params[mmal.MMAL_PARAMETER_DRAW_BOX_FACES_AND_FOCUS] = 1

MMAL_PARAMETER_DRAW_BOX_FACES_AND_FOCUS needs to be added to picamera/

Code: Select all

    mmal.MMAL_PARAMETER_ZOOM:                           mmal.MMAL_PARAMETER_SCALEFACTOR_T,

In order to make use of the new picamera without overwriting system picamera, sample python scripts making use of changed picamera have to be placed in picamera top level directory, that is all.

More details in this thread:

My picamera fork ("This branch is 3 commits ahead of waveform80:master"):

Code: Select all

🍓 python ~/picamera/ 
results in this:

Posts: 374
Joined: Wed Sep 04, 2013 10:20 am
Location: Staffordshire
Contact: Website

Re: Enhancing picamera with new MMAL features

Sun May 17, 2020 8:03 am

OOh! that's really useful. I've just made a stepper motor based focuser for a canon lens, driven from my pi and I have a python app that drives the camera, auto focus is the next step....

Return to “Python”