libcamera
v0.5.0
Supporting cameras in Linux since 2019
|
An auto-focus algorithm based on IPU3 statistics. More...
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... | |
![]() | |
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 | |
![]() | |
using | Module = _Module |
The IPA module type for this class of algorithms. | |
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.
|
override |
Configure the Af given a configInfo.
[in] | context | The shared IPA context |
[in] | configInfo | The IPA configuration data |
|
override |
Fill the params buffer with ISP processing parameters for a frame.
[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.
|
override |
Determine the max contrast image and lens position.
[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