A abstract camera sensor.
The CameraSensor class eases handling of sensors for pipeline handlers by hiding the details of the kernel API and caching sensor information.
libcamera::CameraSensor::computeTransform |
( |
Orientation * |
orientation | ) |
const |
|
pure virtual |
Compute the Transform that gives the requested orientation.
- Parameters
-
[in,out] | orientation | The desired image orientation |
This function computes the Transform that the pipeline handler should apply to the CameraSensor to obtain the requested orientation.
The intended caller of this function is the validate() implementation of pipeline handlers, that pass in the application requested CameraConfiguration::orientation and obtain a Transform to apply to the camera sensor, likely at configure() time.
If the requested orientation cannot be obtained, the orientation parameter is adjusted to report the current image orientation and Transform::Identity is returned.
If the requested orientation can be obtained, the function computes a Transform and does not adjust orientation.
Pipeline handlers are expected to verify if orientation has been adjusted by this function and set the CameraConfiguration::status to Adjusted accordingly.
- Returns
- A Transform instance that applied to the CameraSensor produces images with orientation
libcamera::CameraSensor::getControls |
( |
const std::vector< uint32_t > & |
ids | ) |
|
|
pure virtual |
Read V4L2 controls from the sensor.
- Parameters
-
[in] | ids | The list of controls to read, specified by their ID |
This function reads the value of all controls contained in ids, and returns their values as a ControlList. The control identifiers are defined by the V4L2 specification (V4L2_CID_*).
If any control in ids is not supported by the device, is disabled (i.e. has the V4L2_CTRL_FLAG_DISABLED flag set), or if any other error occurs during validation of the requested controls, no control is read and this function returns an empty control list.
- See also
- V4L2Device::getControls()
- Returns
- The control values in a ControlList on success, or an empty list on error
libcamera::CameraSensor::getFormat |
( |
const std::vector< unsigned int > & |
mbusCodes, |
|
|
const Size & |
size, |
|
|
const Size |
maxSize = Size() |
|
) |
| const |
|
pure virtual |
Retrieve the best sensor format for a desired output.
- Parameters
-
[in] | mbusCodes | The list of acceptable media bus codes |
[in] | size | The desired size |
[in] | maxSize | The maximum size |
Media bus codes are selected from mbusCodes, which lists all acceptable codes in decreasing order of preference. Media bus codes supported by the sensor but not listed in mbusCodes are ignored. If none of the desired codes is supported, it returns an error.
size indicates the desired size at the output of the sensor. This function selects the best media bus code and size supported by the sensor according to the following criteria.
- The desired size shall fit in the sensor output size to avoid the need to up-scale.
- The sensor output size shall match the desired aspect ratio to avoid the need to crop the field of view.
- The sensor output size shall be as small as possible to lower the required bandwidth.
- The desired size shall be supported by one of the media bus code listed in mbusCodes.
- The desired size shall fit into the maximum size maxSize if it is not null.
When multiple media bus codes can produce the same size, the code at the lowest position in mbusCodes is selected.
The use of this function is optional, as the above criteria may not match the needs of all pipeline handlers. Pipeline handlers may implement custom sensor format selection when needed.
The returned sensor output format is guaranteed to be acceptable by the setFormat() function without any modification.
- Returns
- The best sensor output format matching the desired media bus codes and size on success, or an empty format otherwise.
Assemble and return the camera sensor info.
- Parameters
-
[out] | info | The camera sensor info |
This function fills info with information that describes the camera sensor and its current configuration. The information combines static data (such as the the sensor model or active pixel array size) and data specific to the current sensor configuration (such as the line length and pixel rate).
Sensor information is only available for raw sensors. When called for a YUV sensor, this function returns -EINVAL.
- Returns
- 0 on success, a negative error code otherwise
libcamera::CameraSensor::setControls |
( |
ControlList * |
ctrls | ) |
|
|
pure virtual |
Write V4L2 controls to the sensor.
- Parameters
-
[in] | ctrls | The list of controls to write |
This function writes the value of all controls contained in ctrls, and stores the values actually applied to the device in the corresponding ctrls entry. The control identifiers are defined by the V4L2 specification (V4L2_CID_*).
If any control in ctrls is not supported by the device, is disabled (i.e. has the V4L2_CTRL_FLAG_DISABLED flag set), is read-only, or if any other error occurs during validation of the requested controls, no control is written and this function returns -EINVAL.
If an error occurs while writing the controls, the index of the first control that couldn't be written is returned. All controls below that index are written and their values are updated in ctrls, while all other controls are not written and their values are not changed.
- See also
- V4L2Device::setControls()
- Returns
- 0 on success or an error code otherwise
- Return values
-
-EINVAL | One of the control is not supported or not accessible |
i | The index of the control that failed |