[libcamera-devel] [RFC PATCH 0/1] Autofocus controls

David Plowman david.plowman at raspberrypi.com
Mon Dec 13 16:22:14 CET 2021


Hi everyone

I thought it was time for a slightly more formal API proposal for AF
(autofocus).

I've sent a patch listing all the new controls that I think we would
need. These controls cover both the use-cases that I can imagine we
(Raspberry Pi) would expect, and I think it covers all the Android
use-cases too. Nonetheless, I think a few words of additional
discussion and questions are warranted.


1. AfState

This closely follows what Android does, only Android duplicates them
all, once for "passive" (aka. continuous) AF and once for "active"
(user-triggered) AF. I can't really see why duplicating them would be
necessary, it seems pretty clear to me what mode we're in, but of
course we could if there is a good reason.

I wondered a bit about having an "Error" state. Maybe that would get
reported if the AfWindow rectangles are ill-defined?

2. AfWindow

Allowing applications to set the AF windows seems required. For
example, you might be running some kind of object or face detector,
and then you want to feed those results back to the AF algorithm.

I was unsure what units to use for the Rectangles. It seemed to me
that you'd want the rectangles automatically to follow whatever
ScalerCrop you are using. For example, doing digital zoom and leaving
the focus windows in a part of the image you can't see seems
particularly unhelpful!

So anyway, I went with the units being "a proportion of the ScalerCrop
region". Can we think of something better? Would floating point
Rectangles be less annoying?

3. AfMode

As you probably already know, I'm not really seeing the need for an
"off" mode as it seems the same as "auto" to me - so I didn't define
one.

One thing I wondered about was "pausing" CAF (continuous AF). You
might want to let it run, then "pause" for a moment to take some
captures, and then let it re-start from where it was previously. How
to accomplish this?

We could have a separate "pause" control, just for CAF. Or I've
suggested that you could set the mode back to "auto" which would have
the same effect. But then how would you go back to CAF "from where it
left off" as opposed to letting it re-start as though it wasn't
running before? Maybe the "pause" control isn't such a bad idea.

4. LensPosition

I've proposed using the lens driver's units for controlling the lens
position. It's easy and naturally mimics what we tend to do for
exposure/gain.

Another option would be to go a bit more Android-y and insist that
zero means "infinity". Android seems to categorise lenses into
"calibrated" and "uncalibrated" types. For the latter type, it looks
like pretty much the only stipulation is that zero means
"infinity". For "calibrated" lenses the units are formally defined to
be dioptres, but I'm thinking that we don't need to go there right
now.

There's also the question of exactly where we get the lens range from.
It will be different for each module, even ones using the same lens
and/or driver - it will in each case be a different subset of the
range that the driver advertises. But I think that's not a question
for this control API.


Hopefully all that's enough to start taking this forward. There are of
course lots of points of detail to think about here, but clearly the
"big picture" is most important in the first instance.

Thanks!

David

David Plowman (1):
  libcamera: controls: Controls for driving AF (autofocus) algorithms

 src/libcamera/control_ids.yaml | 227 ++++++++++++++++++++++++---------
 1 file changed, 167 insertions(+), 60 deletions(-)

-- 
2.30.2



More information about the libcamera-devel mailing list