libcamera  v0.5.0
Supporting cameras in Linux since 2019
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | List of all members
libcamera::ipa::ipu3::algorithms::Af Class Reference

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

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

Public Member Functions

int configure (IPAContext &context, const IPAConfigInfo &configInfo) override
 Configure the Af given a configInfo. More...
 
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. More...
 
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. More...
 
- Public Member Functions inherited from libcamera::ipa::Algorithm< _Module >
virtual int init ([[maybe_unused]] typename Module::Context &context, [[maybe_unused]] const YamlObject &tuningData)
 Initialize the Algorithm with tuning data. More...
 
virtual int configure ([[maybe_unused]] typename Module::Context &context, [[maybe_unused]] const typename Module::Config &configInfo)
 Configure the Algorithm given an IPAConfigInfo. More...
 
virtual void queueRequest ([[maybe_unused]] typename Module::Context &context, [[maybe_unused]] const uint32_t frame, [[maybe_unused]] typename Module::FrameContext &frameContext, [[maybe_unused]] const ControlList &controls)
 Provide control values to the algorithm. More...
 
virtual void prepare ([[maybe_unused]] typename Module::Context &context, [[maybe_unused]] const uint32_t frame, [[maybe_unused]] typename Module::FrameContext &frameContext, [[maybe_unused]] typename Module::Params *params)
 Fill the params buffer with ISP processing parameters for a frame. More...
 
virtual void process ([[maybe_unused]] typename Module::Context &context, [[maybe_unused]] const uint32_t frame, [[maybe_unused]] typename Module::FrameContext &frameContext, [[maybe_unused]] const typename Module::Stats *stats, [[maybe_unused]] ControlList &metadata)
 Process ISP statistics, and run algorithm operations. More...
 

Additional Inherited Members

- Public Types inherited from libcamera::ipa::Algorithm< _Module >
using Module = _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]contextThe shared IPA context
[in]configInfoThe 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]contextThe shared IPA context
[in]frameThe frame context sequence number
[in]frameContextThe FrameContext for this frame
[out]paramsThe 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]contextThe IPA context
[in]frameThe frame context sequence number
[in]frameContextThe current frame context
[in]statsThe statistics buffer of IPU3
[out]metadataMetadata 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: