diff options
author | Jacopo Mondi <jacopo.mondi@ideasonboard.com> | 2023-06-14 12:46:09 +0200 |
---|---|---|
committer | Jacopo Mondi <jacopo.mondi@ideasonboard.com> | 2023-06-19 10:58:12 +0200 |
commit | 9c666075f3e8886217a4c557a6a59112a139e98f (patch) | |
tree | 6b63eaf9d043bd44051f873797b89e69c8adaf8b /src/libcamera/camera_sensor.cpp | |
parent | 5a142438b025b448eedfa67678fe8e169c66f566 (diff) |
libcamera: camera_sensor: Adjust properties::Rotation
As the CameraSensor::validateTransform() function compensate
for the sensor's mounting rotation, the properties::Rotation value
should be adjusted to make sure application that receive already
"corrected" images do not get confused by Rotation still reporting
a value.
Howerver, as an image sensor can only compensate rotations by applying
H/V flips, only correct Rotation when the mounting rotation is 180
degrees.
Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Diffstat (limited to 'src/libcamera/camera_sensor.cpp')
-rw-r--r-- | src/libcamera/camera_sensor.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index 60bf87b4..f3a5aa37 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -461,7 +461,17 @@ int CameraSensor::initProperties() const auto &rotationControl = controls.find(V4L2_CID_CAMERA_SENSOR_ROTATION); if (rotationControl != controls.end()) { + /* + * validateTransform() compensates for the mounting rotation. + * However, as a camera sensor can only compensate rotations + * by applying H/VFlips, only rotation of 180 degrees are + * automatically compensated. The other valid rotations (Rot90 + * and Rot270) require transposition, which the camera sensor + * cannot perform, so leave them untouched. + */ propertyValue = rotationControl->second.def().get<int32_t>(); + if (propertyValue == 180 && supportFlips_) + propertyValue = 0; properties_.set(properties::Rotation, propertyValue); } @@ -1028,10 +1038,15 @@ void CameraSensor::updateControlInfo() */ Transform CameraSensor::validateTransform(Transform *transform) const { - /* Adjust the requested transform to compensate the sensor rotation. */ - int32_t rotation = properties().get(properties::Rotation).value_or(0); - bool success; + /* Adjust the requested transform to compensate the sensor mounting rotation. */ + const ControlInfoMap &controls = subdev_->controls(); + int rotation = 0; + const auto &rotationControl = controls.find(V4L2_CID_CAMERA_SENSOR_ROTATION); + if (rotationControl != controls.end()) + rotation = rotationControl->second.def().get<int32_t>(); + + bool success; Transform rotationTransform = transformFromRotation(rotation, &success); if (!success) LOG(CameraSensor, Warning) << "Invalid rotation of " << rotation |