Loading...
Searching...
No Matches
libcamera::ipa::ipu3::algorithms::Af Class Reference

An auto-focus algorithm based on IPU3 statistics. More...

Inheritance diagram for libcamera::ipa::ipu3::algorithms::Af:
[legend]
Collaboration diagram for libcamera::ipa::ipu3::algorithms::Af:
[legend]

## Public Member Functions

int | configure (IPAContext &context, const IPAConfigInfo &configInfo) override
| Configure the Af given a configInfo.
void | prepare (IPAContext &context, const uint32_t frame, IPAFrameContext &frameContext, ipu3_uapi_params *params) override
| Fill the params buffer with ISP processing parameters for a frame.
void | process (IPAContext &context, const uint32_t frame, IPAFrameContext &frameContext, const ipu3_uapi_stats_3a *stats, ControlList &metadata) override
| Determine the max contrast image and lens position.
Public Member Functions inherited from libcamera::ipa::Algorithm< Module >
virtual int | init (typename Module::Context &context, const YamlObject &tuningData)
| Initialize the Algorithm with tuning data.
virtual int | configure (typename Module::Context &context, const typename Module::Config &configInfo)
| Configure the Algorithm given an IPAConfigInfo.
virtual void | queueRequest (typename Module::Context &context, const uint32_t frame, typename Module::FrameContext &frameContext, const ControlList &controls)
| Provide control values to the algorithm.
virtual void | prepare (typename Module::Context &context, const uint32_t frame, typename Module::FrameContext &frameContext, typename Module::Params *params)
| Fill the params buffer with ISP processing parameters for a frame.
virtual void | process (typename Module::Context &context, const uint32_t frame, typename Module::FrameContext &frameContext, const typename Module::Stats *stats, ControlList &metadata)
| Process ISP statistics, and run algorithm operations.

## Additional Inherited Members

Public Types inherited from libcamera::ipa::Algorithm< Module >
using | Module
| The IPA module type for this class of algorithms.

## Detailed Description

An auto-focus algorithm based on IPU3 statistics.

This algorithm is used to determine the position of the lens to make a focused image. The IPU3 AF processing block computes the statistics that are composed by two types of filtered value and stores in a AF buffer. Typically, for a clear image, it has a relatively higher contrast than a blurred one. Therefore, if an image with the highest contrast can be found through the scan, the position of the len indicates to a clearest image.

## Member Function Documentation

## configure()

int libcamera::ipa::ipu3::algorithms::Af::configure | ( | IPAContext & | context,
|  | const IPAConfigInfo & | configInfo )

override

Configure the Af given a configInfo.

Parameters

  [in] | context | The shared IPA context
  [in] | configInfo | The IPA configuration data

Returns
  0 on success, a negative error code otherwise

## prepare()

void libcamera::ipa::ipu3::algorithms::Af::prepare | ( | IPAContext & | context,
|  | const uint32_t | frame,
|  | IPAFrameContext & | frameContext,
|  | ipu3_uapi_params * | params )

override

Fill the params buffer with ISP processing parameters for a frame.

Parameters

  [in] | context | The shared IPA context
  [in] | frame | The frame context sequence number
  [in] | frameContext | The FrameContext for this frame
  [out] | params | The ISP specific parameters

This function is called for every frame when the camera is running before it is processed by the ISP to prepare the ISP processing parameters for that frame.

Algorithms shall fill in the parameter structure fields appropriately to configure the ISP processing blocks that they are responsible for. This includes setting fields and flags that enable those processing blocks.

## process()

void libcamera::ipa::ipu3::algorithms::Af::process | ( | IPAContext & | context,
|  | const uint32_t | frame,
|  | IPAFrameContext & | frameContext,
|  | const ipu3_uapi_stats_3a * | stats,
|  | ControlList & | metadata )

override

Determine the max contrast image and lens position.

Parameters

  [in] | context | The IPA context
  [in] | frame | The frame context sequence number
  [in] | frameContext | The current frame context
  [in] | stats | The statistics buffer of IPU3
  [out] | metadata | Metadata for the frame, to be filled by the algorithm

Ideally, a clear image also has a relatively higher contrast. So, every image for each focus step should be tested to find an optimal focus step.

The Hill Climbing Algorithm[1] is used to find the maximum variance of the AF statistics which is the AF output of IPU3. The focus step is increased then the variance of the AF statistics are estimated. If it finds the negative derivative we have just passed the peak, and we infer that the best focus is found.

[1] Hill Climbing Algorithm, https://en.wikipedia.org/wiki/Hill_climbing

The documentation for this class was generated from the following files:

- src/ipa/ipu3/algorithms/af.h
- src/ipa/ipu3/algorithms/af.cpp