libcamera: libcamera::ipa::Interpolator< T > Class Template Reference

libcamera v0.4.0 Supporting cameras in Linux since 2019 |

Loading...
Searching...
No Matches
Public Member Functions | List of all members
libcamera::ipa::Interpolator< T > Class Template Reference

Class for storing, retrieving, and interpolating objects. More...

## Public Member Functions
| Interpolator ()=default
| Construct an empty interpolator.
| Interpolator (const std::map< unsigned int, T > &data)
| Construct an interpolator from a map of objects.
| Interpolator (std::map< unsigned int, T > &&data)
| Construct an interpolator from a map of objects.
int | readYaml (const libcamera::YamlObject &yaml, const std::string &key_name, const std::string &value_name)
| Initialize an Interpolator instance from yaml.
void | setQuantization (const unsigned int q)
| Set the quantization value.
void | setData (std::map< unsigned int, T > &&data)
| Set the internal map.
const T & | getInterpolated (unsigned int key, unsigned int *quantizedKey=nullptr)
| Retrieve an interpolated value for the given key.
void | interpolate (const T &a, const T &b, T &dest, double lambda)
| Interpolate between two instances of T.

## Detailed Description

template<typename T>
class libcamera::ipa::Interpolator< T >

Class for storing, retrieving, and interpolating objects.

Template Parameters

  T | Type of objects stored in the interpolator

The main use case is to pass a map from color temperatures to corresponding objects (eg. matrices for color correction), and then requesting a interpolated object for a specific color temperature. This class will abstract away the interpolation portion.

## Constructor & Destructor Documentation

## ◆ Interpolator() [1/2]

template<typename T>

libcamera::ipa::Interpolator< T >::Interpolator | ( | const std::map< unsigned int, T > & | data | ) |
| inline

Construct an interpolator from a map of objects.

Parameters

  data | Map from which to construct the interpolator

## ◆ Interpolator() [2/2]

template<typename T>

libcamera::ipa::Interpolator< T >::Interpolator | ( | std::map< unsigned int, T > && | data | ) |
| inline

Construct an interpolator from a map of objects.

Parameters

  data | Map from which to construct the interpolator

## Member Function Documentation

## ◆ getInterpolated()

template<typename T>

const T & libcamera::ipa::Interpolator< T >::getInterpolated | ( | unsigned int | key,
|  | unsigned int * | quantizedKey = nullptr )
| inline

Retrieve an interpolated value for the given key.

Parameters

  [in] | key | The unsigned integer key of the object to retrieve
  [out] | quantizedKey | If provided, the key value after quantization

Returns
  The object corresponding to the key. The object is cached internally, so on successive calls with the same key (after quantization) interpolation is not recalculated.

## ◆ interpolate()

template<typename T>

void libcamera::ipa::Interpolator< T >::interpolate | ( | const T & | a,
|  | const T & | b,
|  | T & | dest,
|  | double | lambda )
| inline

Interpolate between two instances of T.

Parameters

  a | The first value to interpolate
  b | The second value to interpolate
  dest | The destination for the interpolated value
  lambda | The interpolation factor (0..1)

Interpolates between a and b according to lambda. It calculates dest = a * (1.0 - lambda) + b * lambda;

If T supports multiplication with double and addition, this function can be used as is. For other types this function can be overwritten using partial template specialization.

## ◆ readYaml()

template<typename T>

int libcamera::ipa::Interpolator< T >::readYaml | ( | const libcamera::YamlObject & | yaml,
|  | const std::string & | key_name,
|  | const std::string & | value_name )
| inline

Initialize an Interpolator instance from yaml.

Template Parameters

  T | Type of data stored in the interpolator

Parameters

  [in] | yaml | The yaml object that contains the map of unsigned integers to objects
  [in] | key_name | The name of the key in the yaml object
  [in] | value_name | The name of the value in the yaml object

The yaml object is expected to be a list of maps. Each map has two or more pairs: one of key_name to the key value (usually color temperature), and one or more of value_name to the object. This is a bit difficult to explain, so here is an example (in python, as it is easier to parse than yaml): [ { 'ct': 2860, 'ccm': [ 2.12089, -0.52461, -0.59629, -0.85342, 2.80445, -0.95103, -0.26897, -1.14788, 2.41685 ], 'offsets': [ 0, 0, 0 ] },

{ 'ct': 2960, 'ccm': [ 2.26962, -0.54174, -0.72789, -0.77008, 2.60271, -0.83262, -0.26036, -1.51254, 2.77289 ], 'offsets': [ 0, 0, 0 ] },

{ 'ct': 3603, 'ccm': [ 2.18644, -0.66148, -0.52496, -0.77828, 2.69474, -0.91645, -0.25239, -0.83059, 2.08298 ], 'offsets': [ 0, 0, 0 ] }, ]

In this case, key_name would be 'ct', and value_name can be either 'ccm' or 'offsets'. This way multiple interpolators can be defined in one set of color temperature ranges in the tuning file, and they can be retrieved separately with the value_name parameter.

Returns
  Zero on success, negative error code otherwise

## ◆ setData()

template<typename T>

void libcamera::ipa::Interpolator< T >::setData | ( | std::map< unsigned int, T > && | data | ) |
| inline

Set the internal map.

Overwrites the internal map using move semantics.

## ◆ setQuantization()

template<typename T>

void libcamera::ipa::Interpolator< T >::setQuantization | ( | const unsigned int | q | ) |
| inline

Set the quantization value.

Parameters

  [in] | q | The quantization value

Sets the quantization value. When this is set, 'key' gets quantized to this size, before doing the interpolation. This can help in reducing the number of updates pushed to the hardware.

Note that normally a threshold needs to be combined with quantization. Otherwise a value that swings around the edge of the quantization step will lead to constant updates.

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

- src/ipa/libipa/interpolator.h
- src/ipa/libipa/interpolator.cpp