[libcamera-devel] [PATCH v5 1/1] libcamera: controls: Controls for driving AF (autofocus) algorithms

Jacopo Mondi jacopo at jmondi.org
Thu May 19 09:05:36 CEST 2022


Hi David,

On Wed, May 18, 2022 at 11:01:50PM +0100, David Plowman wrote:
> Hi Jacopo
>
> Thanks for the reply. Re-reading that bit of text I agree that you
> have a point, I don't think I like it either!
>

[snip]

> > > +  - LensPosition:
> > > +      type: float
> > > +      description: |
> > > +        Acts as a control to instruct the lens to move to a particular position
> > > +        and also reports back the position of the lens for each frame.
> > > +
> > > +        The LensPosition control is ignored unless the AfMode is set to
> > > +        AfModeManual, though the value is reported back unconditionally in all
> > > +        modes.
> > > +
> > > +        The units are dioptres divided by the hyperfocal distance. Non-integer
> > > +        values are permitted. For example:
> >
> > My understanding is that the unit of the control is "a dioptre-like
> > scale normalized in the lens' hyperfocal distance". The use of the term
> > "divided" drives me off road everytime, but maybe it's just me ? Or
> > maybe I didn't really get how the units are expressed at all :)
> >
> > Thanks
> >    j
>
> I agree "divided" isn't the right word and it's not a great
> description. The examples below are exactly right, so maybe the text
> wants re-wording, perhaps like this:
>
> "The units are a reciprocal distance scale like dioptres but
> normalised for the hyperfocal distance. That is, for a lens with
> hyperfocal distance H, and setting it to a focal distance D, the lens
> position LP, which is generally a non-integer, is given by
>
> LP = H / D
>
> For example:"
>
> Does that sound better?
>

Thanks, it's much more clear to me.

Let's wait for more comments, and if there are no objections the text
can be updated when applying the patch!

Thank you!
    j

> Thanks!
> David
>
> >
> > > +        0 moves the lens to infinity.
> > > +        0.5 moves the lens to twice the hyperfocal distance.
> > > +        1 moves the lens to the hyperfocal position.
> > > +        And larger values will focus the lens ever closer.
> > > +
> > > +        \todo Define a property to report the Hyperforcal distance of calibrated
> > > +        lenses.
> > > +
> > > +        \todo Define a property to report the maximum and minimum positions of
> > > +        this lens. The minimum value will often be zero (meaning infinity).
> > > +
> > > +  - AfState:
> > > +      type: int32_t
> > > +      description: |
> > > +        Reports the current state of the AF algorithm in conjunction with the
> > > +        reported AfMode value and (in continuous AF mode) the AfPauseState
> > > +        value. The possible state changes are described below, though we note
> > > +        the following state transitions that occur when the AfMode is changed.
> > > +
> > > +        If the AfMode is set to AfModeManual, then the AfState will always
> > > +        report AfStateIdle (even if the lens is subsequently moved). Changing to
> > > +        the AfModeManual state does not initiate any lens movement.
> > > +
> > > +        If the AfMode is set to AfModeAuto then the AfState will report
> > > +        AfStateIdle. However, if AfModeAuto and AfTriggerStart are sent together
> > > +        then AfState will omit AfStateIdle and move straight to AfStateScanning
> > > +        (and start a scan).
> > > +
> > > +        If the AfMode is set to AfModeContinuous then the AfState will initially
> > > +        report AfStateScanning.
> > > +
> > > +      enum:
> > > +        - name: AfStateIdle
> > > +          value: 0
> > > +          description: |
> > > +            The AF algorithm is in manual mode (AfModeManual) or in auto mode
> > > +            (AfModeAuto) and a scan has not yet been triggered, or an
> > > +            in-progress scan was cancelled.
> > > +        - name: AfStateScanning
> > > +          value: 1
> > > +          description: |
> > > +            The AF algorithm is in auto mode (AfModeAuto), and a scan has been
> > > +            started using the AfTrigger control. The scan can be cancelled by
> > > +            sending AfTriggerCancel at which point the algorithm will either
> > > +            move back to AfStateIdle or, if the scan actually completes before
> > > +            the cancel request is processed, to one of AfStateFocused or
> > > +            AfStateFailed.
> > > +
> > > +            Alternatively the AF algorithm could be in continuous mode
> > > +            (AfModeContinuous) at which point it may enter this state
> > > +            spontaneously whenever it determines that a rescan is needed.
> > > +        - name: AfStateFocused
> > > +          value: 2
> > > +          description: |
> > > +            The AF algorithm is in auto (AfModeAuto) or continuous
> > > +            (AfModeContinuous) mode and a scan has completed with the result
> > > +            that the algorithm believes the image is now in focus.
> > > +        - name: AfStateFailed
> > > +          value: 3
> > > +          description: |
> > > +            The AF algorithm is in auto (AfModeAuto) or continuous
> > > +            (AfModeContinuous) mode and a scan has completed with the result
> > > +            that the algorithm did not find a good focus position.
> > > +
> > > +  - AfPauseState:
> > > +      type: int32_t
> > > +      description: |
> > > +        Only applicable in continuous (AfModeContinuous) mode, this reports
> > > +        whether the algorithm is currently running, paused or pausing (that is,
> > > +        will pause as soon as any in-progress scan completes).
> > > +
> > > +        Any change to AfMode will cause AfPauseStateRunning to be reported.
> > > +
> > > +      enum:
> > > +        - name: AfPauseStateRunning
> > > +          value: 0
> > > +          description: |
> > > +            Continuous AF is running and the algorithm may restart a scan
> > > +            spontaneously.
> > > +        - name: AfPauseStatePausing
> > > +          value: 1
> > > +          description: |
> > > +            Continuous AF has been sent an AfPauseDeferred control, and will
> > > +            pause as soon as any in-progress scan completes (and then report
> > > +            AfPauseStatePaused). No new scans will be start spontaneously until
> > > +            the AfPauseResume control is sent.
> > > +        - name: AfPauseStatePaused
> > > +          value: 2
> > > +          description: |
> > > +            Continuous AF is paused. No further state changes or lens movements
> > > +            will occur until the AfPauseResume control is sent.
> > > +
> > >    # ----------------------------------------------------------------------------
> > >    # Draft controls section
> > >
> > > @@ -406,27 +700,6 @@ controls:
> > >              The camera will cancel any active or completed metering sequence.
> > >              The AE algorithm is reset to its initial state.
> > >
> > > -  - AfTrigger:
> > > -      type: int32_t
> > > -      draft: true
> > > -      description: |
> > > -       Control for AF trigger. Currently identical to
> > > -       ANDROID_CONTROL_AF_TRIGGER.
> > > -
> > > -        Whether the camera device will trigger autofocus for this request.
> > > -      enum:
> > > -        - name: AfTriggerIdle
> > > -          value: 0
> > > -          description: The trigger is idle.
> > > -        - name: AfTriggerStart
> > > -          value: 1
> > > -          description: The AF routine is started by the camera.
> > > -        - name: AfTriggerCancel
> > > -          value: 2
> > > -          description: |
> > > -            The camera will cancel any active trigger and the AF routine is
> > > -            reset to its initial state.
> > > -
> > >    - NoiseReductionMode:
> > >        type: int32_t
> > >        draft: true
> > > @@ -507,45 +780,6 @@ controls:
> > >              The AE algorithm has started a pre-capture metering session.
> > >              \sa AePrecaptureTrigger
> > >
> > > -  - AfState:
> > > -      type: int32_t
> > > -      draft: true
> > > -      description: |
> > > -       Control to report the current AF algorithm state. Currently identical to
> > > -       ANDROID_CONTROL_AF_STATE.
> > > -
> > > -        Current state of the AF algorithm.
> > > -      enum:
> > > -        - name: AfStateInactive
> > > -          value: 0
> > > -          description: The AF algorithm is inactive.
> > > -        - name: AfStatePassiveScan
> > > -          value: 1
> > > -          description: |
> > > -            AF is performing a passive scan of the scene in continuous
> > > -            auto-focus mode.
> > > -        - name: AfStatePassiveFocused
> > > -          value: 2
> > > -          description: |
> > > -            AF believes the scene is in focus, but might restart scanning.
> > > -        - name: AfStateActiveScan
> > > -          value: 3
> > > -          description: |
> > > -            AF is performing a scan triggered by an AF trigger request.
> > > -            \sa AfTrigger
> > > -        - name: AfStateFocusedLock
> > > -          value: 4
> > > -          description: |
> > > -            AF believes has focused correctly and has locked focus.
> > > -        - name: AfStateNotFocusedLock
> > > -          value: 5
> > > -          description: |
> > > -            AF has not been able to focus and has locked.
> > > -        - name: AfStatePassiveUnfocused
> > > -          value: 6
> > > -          description: |
> > > -            AF has completed a passive scan without finding focus.
> > > -
> > >    - AwbState:
> > >        type: int32_t
> > >        draft: true
> > > --
> > > 2.30.2
> > >


More information about the libcamera-devel mailing list