Loading...
Searching...
No Matches
libcamera::Dw100VertexMap Class Reference

Helper class to compute dw100 vertex maps. More...

## Public Types

enum | ScaleMode { Fill = 0 , Crop = 1 }
| The scale modes available for a vertex map. More...

## Public Member Functions

void | applyLimits ()
| Apply limits on scale and offset.
void | setInputSize (const Size &size)
| Set the size of the input data.
void | setSensorCrop (const Rectangle &rect)
| Set the crop rectangle that represents the input data.
void | setScalerCrop (const Rectangle &rect)
| Set the requested scaler crop.
const Rectangle & | effectiveScalerCrop () const
| Get the effective scaler crop.
void | setOutputSize (const Size &size)
| Set the output size.
const Size & | outputSize () const
| Get the output size.
void | setTransform (const Transform &transform)
| Sets the transform to apply.
const Transform & | transform () const
| Get the transform.
void | setScale (const float scale)
| Sets the scale to apply.
float | effectiveScale () const
| Get the effective scale.
void | setRotation (const float rotation)
| Sets the rotation to apply.
float | rotation () const
| Get the rotation.
void | setOffset (const Point &offset)
| Sets the offset to apply.
const Point & | effectiveOffset () const
| Get the effective offset.
void | setMode (const ScaleMode mode)
| Sets the scaling mode to apply.
ScaleMode | mode () const
| Get the scaling mode.
int | setDewarpParams (const Matrix< double, 3, 3 > &cm, const Span< const double > &coeffs)
| Set the dewarp parameters.
bool | dewarpParamsValid ()
| Returns if the dewarp parameters are valid.
void | setLensDewarpEnable (bool enable)
| Enables or disables lens dewarping.
bool | lensDewarpEnable ()
| Returns if lens dewarping is enabled.
std::vector< uint32_t > | getVertexMap ()
| Get the dw100 vertex map.

## Detailed Description

Helper class to compute dw100 vertex maps.

The vertex map class represents a helper for handling dewarper vertex maps. There are 3 important sizes in the system:

- The sensor size. The number of pixels of the whole sensor.
- The input rectangle to the dewarper. Describes the pixel data flowing into the dewarper in sensor coordinates.
- ScalerCrop rectangle. The rectangle that shall be used for all further stages. It is applied after lens dewarping but is in sensor coordinate space.
- The output size. This defines the size, the dewarper should output.

+---------------------—+ |Sensor size | | +-------------—+ | | | Input rect | | | | +----------—+ | | | | ScalerCrop | | | | | | | | +–+----------—+ | +---------------------—+

This class implements a vertex map that forms the following pipeline:

+----------—+ +----------—+ +---------—+ +--------------—+ | | | | | Transform | | Pan/Zoom | | Lens Dewarp | -> | Scaler Crop | -> | (H/V Flip, | -> | (Offset, Scale, | | | | | | Transpose) | | Rotate) | +----------—+ +----------—+ +---------—+ +--------------—+

All parameters are clamped to valid values before creating the vertex map.

The constraints process works as follows:

- The ScalerCrop rectangle is clamped to the input rectangle
- The ScalerCrop rectangle is transformed by the specified transform forming ScalerCropT
- A rectangle of output size is placed in the center of ScalerCropT (OutputRect).
- Rotate gets applied to OutputRect,
- Scale is applied, but clamped so that the OutputRect fits completely into ScalerCropT (Only regarding dimensions, not position)
- Offset is clamped so that the OutputRect lies inside ScalerCropT

After applying the limits, the actual values used for processing are stored effectiveXXX members and can be queried using the corresponding functions.

The lens dewarp map is usually calibrated during tuning and is a map that maps from incoming pixels to dewarped pixels.

## Member Enumeration Documentation

## ScaleMode

enum libcamera::Dw100VertexMap::ScaleMode

The scale modes available for a vertex map.

Enumerator
Fill | Scale the input to fill the output. This scale mode does not preserve aspect ratio. Offset and rotation are taken into account.
Crop | Crop the input. This scale mode preserves the aspect ratio. Offset, scale, rotation are taken into account within the possible limits.

## Member Function Documentation

## applyLimits()

void libcamera::Dw100VertexMap::applyLimits | ( |  | ) |

Apply limits on scale and offset.

This function calculates effectiveScalerCrop_, effectiveScale_ and effectiveOffset_ based on the requested scaler crop, scale, rotation, offset and the selected scale mode, so that the whole output area is filled with valid input data.

## dewarpParamsValid()

bool libcamera::Dw100VertexMap::dewarpParamsValid | ( |  | ) |

inline

Returns if the dewarp parameters are valid.

Returns
  True if the dewarp parameters are valid, false otherwise

## effectiveOffset()

const Point & libcamera::Dw100VertexMap::effectiveOffset | ( |  | ) | const

inline

Get the effective offset.

Returns the actual offset applied to the input pixels in ScalerCrop coordinates.

Returns
  The effective offset

## effectiveScale()

float libcamera::Dw100VertexMap::effectiveScale | ( |  | ) | const

inline

Get the effective scale.

Returns the actual scale applied to the input pixels in x and y direction. So a value of [2.0, 1.5] means that every input pixel is scaled to cover 2 output pixels in x-direction and 1.5 in y-direction.

Returns
  The effective scale

## effectiveScalerCrop()

const Rectangle & libcamera::Dw100VertexMap::effectiveScalerCrop | ( |  | ) | const

inline

Get the effective scaler crop.

Returns
  The effective scaler crop

## getVertexMap()

std::vector< uint32_t > libcamera::Dw100VertexMap::getVertexMap | ( |  | ) |

Get the dw100 vertex map.

Calculates the vertex map as a vector of hardware specific entries.

Returns
  The vertex map

## mode()

ScaleMode libcamera::Dw100VertexMap::mode | ( |  | ) | const

inline

Get the scaling mode.

Returns
  The scaling mode

## outputSize()

const Size & libcamera::Dw100VertexMap::outputSize | ( |  | ) | const

inline

Get the output size.

Returns
  The output size

## rotation()

float libcamera::Dw100VertexMap::rotation | ( |  | ) | const

inline

Get the rotation.

Returns
  The rotation in degrees

## setDewarpParams()

int libcamera::Dw100VertexMap::setDewarpParams | ( | const Matrix< double, 3, 3 > & | cm,
|  | const Span< const double > & | coeffs )

Set the dewarp parameters.

Parameters

  cm | The camera matrix
  coeffs | The dewarp coefficients

Sets the dewarp parameters according to the commonly used dewarp model. See https://docs.opencv.org/4.12.0/d9/d0c/group__calib3d.html for further details on the model. The parameter coeffs must either hold 4,5,8 or 12 values. They represent the parameters k1,k2,p1,p2[,k3[,k4,k5,k6[,s1,s2,s3,s4]]] in the model.

Returns
  A negative number on error, 0 otherwise

## setInputSize()

void libcamera::Dw100VertexMap::setInputSize | ( | const Size & | size | ) |

inline

Set the size of the input data.

Parameters

  [in] | size | The input size

To calculate a proper vertex map, the size of the input images must be set.

## setLensDewarpEnable()

void libcamera::Dw100VertexMap::setLensDewarpEnable | ( | bool | enable | ) |

inline

Enables or disables lens dewarping.

Parameters

  [in] | enable | Enable or disable lens dewarping

## setMode()

void libcamera::Dw100VertexMap::setMode | ( | const ScaleMode | mode | ) |

inline

Sets the scaling mode to apply.

Parameters

  [in] | mode | The mode

## setOffset()

void libcamera::Dw100VertexMap::setOffset | ( | const Point & | offset | ) |

inline

Sets the offset to apply.

Parameters

  [in] | offset | The offset

Set the requested offset. The actually applied offset can be queried using Dw100VertexMap::effectiveOffset() after calling Dw100VertexMap::applyLimits().

## setOutputSize()

void libcamera::Dw100VertexMap::setOutputSize | ( | const Size & | size | ) |

inline

Set the output size.

Parameters

  [in] | size | The size of the output images

## setRotation()

void libcamera::Dw100VertexMap::setRotation | ( | const float | rotation | ) |

inline

Sets the rotation to apply.

Parameters

  [in] | rotation | The rotation in degrees

The rotation is in clockwise direction to allow the same transform as CameraConfiguration::orientation

## setScale()

void libcamera::Dw100VertexMap::setScale | ( | const float | scale | ) |

inline

Sets the scale to apply.

Parameters

  [in] | scale | The scale

Set the requested scale. The actually applied scale can be queried using Dw100VertexMap::effectiveScale() after calling Dw100VertexMap::applyLimits().

## setScalerCrop()

void libcamera::Dw100VertexMap::setScalerCrop | ( | const Rectangle & | rect | ) |

inline

Set the requested scaler crop.

Parameters

  [in] | rect |

Set the requested scaler crop. The actually applied scaler crop can be queried using Dw100VertexMap::effectiveScalerCrop() after calling Dw100VertexMap::applyLimits().

## setSensorCrop()

void libcamera::Dw100VertexMap::setSensorCrop | ( | const Rectangle & | rect | ) |

inline

Set the crop rectangle that represents the input data.

Parameters

  [in] | rect |

Set the rectangle that represents the input data in sensor coordinates. This must be specified to properly calculate the vertex map.

## setTransform()

void libcamera::Dw100VertexMap::setTransform | ( | const Transform & | transform | ) |

inline

Sets the transform to apply.

Parameters

  [in] | transform | The transform

## transform()

const Transform & libcamera::Dw100VertexMap::transform | ( |  | ) | const

inline

Get the transform.

Returns
  The transform

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

- include/libcamera/internal/converter/converter_dw100_vertexmap.h
- src/libcamera/converter/converter_dw100_vertexmap.cpp