|
libcamera v0.7.2+rpt20260817
Supporting cameras in Linux since 2019
|
libIPA LSC algorithm implementation More...


Public Member Functions | |
| int | configure (lsc::ActiveState &state, const Rectangle &analogCrop, const std::vector< double > &xPos, const std::vector< double > &yPos) |
| Re-sample and quantize LSC data. | |
| const Components | interpolateComponents (unsigned int ct) |
| Interpolate the LSC tables for a given colour temperature. | |
| const ComponentsMap & | getComponents () const |
| Return the map of LSC data per-colour-temperature. | |
Public Member Functions inherited from libcamera::ipa::LscAlgorithmBase | |
| int | init (const ValueNode &tuningData, ControlInfoMap::Map &controls, const LscDescriptor &descriptor) |
| void | queueRequest (lsc::ActiveState &state, lsc::FrameContext &context, const ControlList &controls) |
| Queue a request to the lsc algorithm. | |
| void | process (lsc::FrameContext &context, ControlList &metadata) |
| Populate the list of lsc metadata. | |
Additional Inherited Members | |
Protected Attributes inherited from libcamera::ipa::LscAlgorithmBase | |
| std::unique_ptr< LscImplementation > | impl_ |
| The LSC algorithm implementation. | |
| bool | polynomial_ |
| Boolean flag for polynomial LSC. | |
libIPA LSC algorithm implementation
| U | The platform fixed-point register format representation |
Due to the optical characteristics of the lens, the light intensity received by the sensor is not uniform. The Lens Shading Correction algorithm applies multipliers to all pixels to compensate for the lens shading effect.
The LscAlgorithm implements the libipa Lens Shading Correction algorithm using an implementation of the LscImplementation interface.
This class provides support for parsing the tuning file content and generates tables indexed by colour temperature to store per-colour-channel gains for the IPA algorithm to be able to program the LSC engine.
The init() function parses the tuning file and loads the gain tables either in tabular form (LscTable) or as radial polynomials (LscPolynomial). The gain tables are indexed by colour temperature with per-colour-components vectors of gain values or polynomial coefficients.
The colour components names are IPA-implementation specific and depend on the ISP LSC engine design. Some LSC engine support 4 colour components (r, gr, gb, b), some only support 3 colour components (r, g, b). The name (and number) of the expected colour components shall be provided to LscAlgorithm::init() using the LscDescriptor::keys field.
Example of a tabular lens shading tuning file with 'r', 'g' and 'b' colour components. The gain table has been omitted here, but the expected number of entries has to be equal to LscDescriptor::numHSamples * LscDescriptor::numVSamples.
Example of a polynomial lens shading tuning file with 'r', 'gr', 'gb' and 'b' colour components:
The LSC polynomial definition is generated at tuning time in relation to the full sensor pixel array. This needs to be specified in LscDescriptor::sensorSize.
At LscAlgorithm::configure() time the LSC tables are re-sampled on the sensor's crop rectangle in use to adapt them to the configuration in use for a streaming session. Polynomial LSC tables support re-sampling and can be applied to any sensor configuration. Grid-based LSC tables cannot currently be re-sampled and the configuration as parsed from the tuning file is used for all sensor configurations providing best-effort results.
After re-sampling, the LSC tables gain values are converted from their floating point representation (LscImplementation::Components) to the platform's register representation (lsc::Components<>). Grid-based LSC tables currently already contain gains represented in register format, so no quantization is necessary but only a simple cast is required.
When the IPA algorithms wants to get access to the (re-sampled) tables to program its LSC engine, it uses LscAlgorithm::interpolateComponents() to get an LSC table interpolated by the LscAlgorithm class for the specified colour temperature. If the algorithm wants to access the non-interpolated tables it can retrieve them using LscAlgorithm::getComponents().
|
inline |
Re-sample and quantize LSC data.
| [in] | state | The LSC active state |
| [in] | analogCrop | The current sensor analog crop rectangle |
| [in] | xPos | List of horizontal positions of the LSC grid nodes |
| [in] | yPos | List of vertical positions of the LSC grid nodes |
Re-sample the LSC data for an analogCrop and convert gains to their register representation using the class template paramter U.
LSC tables are generated at tuning time using a known sensor configuration. When a new streaming session is started, it might use a different sensor configuration for which the LSC tables need to be adjusted to.
This function re-generates the LSC tables to adapt them to a new sensor configuration, specifically it re-samples the LSC data for a new analogCrop on a grid specified by xPos and yPos. Re-sampling of LSC data is currently supported by polynomial-based LSC tables.
Once tables have been re-sampled, they get quantized to the platform's fixed-point register representation using the LscAlgorithm template parameter U.
|
inline |
Return the map of LSC data per-colour-temperature.
Calling this function is only valid after LscAlgorithm::configure() has been called. An empty components list is returned otherwise.
|
inline |
Interpolate the LSC tables for a given colour temperature.
| [in] | ct | The colour temperature |
LSC tables are generated using different colour temperatures during the tuning phase.
This function returns the interpolated LSC data for a given ct colour temperature.
IPA algorithm can use this function to obtain a list of per-colour-component gains to program their LSC engines with every time a significant enough change in colour temperature is detected.
Calling this function is only valid after LscAlgorithm::configure() has been called. An empty components list is returned otherwise.