libcamera v0.0.0+3240-f2a18172-dirty (2022-02-06T09:24:04+00:00)
Supporting cameras in Linux since 2019
|
The IPU3 IPA implementation. More...
Public Member Functions | |
int | init (const IPASettings &settings, const IPACameraSensorInfo &sensorInfo, const ControlInfoMap &sensorControls, ControlInfoMap *ipaControls) override |
Initialize the IPA module and its controls. More... | |
int | start () override |
Perform any processing required before the first frame. | |
void | stop () override |
Ensure that all processing has completed. | |
int | configure (const IPAConfigInfo &configInfo, ControlInfoMap *ipaControls) override |
Configure the IPU3 IPA. More... | |
void | mapBuffers (const std::vector< IPABuffer > &buffers) override |
Map the parameters and stats buffers allocated in the pipeline handler. More... | |
void | unmapBuffers (const std::vector< unsigned int > &ids) override |
Unmap the parameters and stats buffers. More... | |
void | processEvent (const IPU3Event &event) override |
Process an event generated by the pipeline handler. More... | |
The IPU3 IPA implementation.
The IPU3 Pipeline defines an IPU3-specific interface for communication between the PipelineHandler and the IPA module.
We extend the IPAIPU3Interface to implement our algorithms and handle events from the IPU3 PipelineHandler to satisfy requests from the application.
At initialisation time, a CameraSensorHelper is instantiated to support camera-specific calculations, while the default controls are computed, and the algorithms are constructed and placed in an ordered list.
The IPU3 ImgU operates with a grid layout to divide the overall frame into rectangular cells of pixels. When the IPA is configured, we determine the best grid for the statistics based on the pipeline handler Bayer Down Scaler output size.
Two main events are then handled to operate the IPU3 ImgU by populating its parameter buffer, and adapting the settings of the sensor attached to the IPU3 CIO2 through sensor-specific V4L2 controls.
When the event EventFillParams occurs we populate the ImgU parameter buffer with settings to configure the device in preparation for handling the frame queued in the Request.
When the frame has completed processing, the ImgU will generate a statistics buffer which is given to the IPA as part of the EventStatReady event. At this event we run the algorithms to parse the statistics and cache any results for the next EventFillParams event.
The individual algorithms are split into modular components that are called iteratively to allow them to process statistics from the ImgU in a defined order.
The current implementation supports three core algorithms:
AWB is implemented using a Greyworld algorithm, and calculates the red and blue gains to apply to generate a neutral grey frame overall.
AGC is handled by calculating a histogram of the green channel to estimate an analogue gain and shutter time which will provide a well exposed frame. A low-pass IIR filter is used to smooth the changes to the sensor to reduce perceivable steps.
The tone mapping algorithm provides a gamma correction table to improve the contrast of the scene.
The black level compensation algorithm subtracts a hardcoded black level from all pixels.
The IPU3 ImgU has further processing blocks to support image quality improvements through bayer and temporal noise reductions, however those are not supported in the current implementation, and will use default settings as provided by the kernel driver.
Demosaicing is operating with the default parameters and could be further optimised to provide improved sharpening coefficients, checker artifact removal, and false color correction.
Additional image enhancements can be made by providing lens and sensor-specific tuning to adapt for Black Level compensation (BLC), Lens shading correction (SHD) and Color correction (CCM).
|
override |
Configure the IPU3 IPA.
[in] | configInfo | The IPA configuration data, received from the pipeline handler |
[in] | ipaControls | The IPA controls to update |
Calculate the best grid for the statistics based on the pipeline handler BDS output, and parse the minimum and maximum exposure and analogue gain control values.
All algorithm modules are called to allow them to prepare the IPASessionConfiguration structure for the IPAContext.
|
override |
Initialize the IPA module and its controls.
This function receives the camera sensor information from the pipeline handler, computes the limits of the controls it handles and returns them in the ipaControls output parameter.
|
override |
Map the parameters and stats buffers allocated in the pipeline handler.
[in] | buffers | The buffers to map |
|
override |
|
override |
Unmap the parameters and stats buffers.
[in] | ids | The IDs of the buffers to unmap |