mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 07:19:45 +03:00
libcamera: camera_sensor: Cache mounting orientation instead of transform
The cached rotationTransform_ value is used in computeTransform() only, to compute the mounting orientation. Cache the mounting orientation instead, removing the need for the intermediate conversion of the rotation to a transform. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
This commit is contained in:
parent
4814d8f1b5
commit
7a5d4b83e5
2 changed files with 10 additions and 11 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include <libcamera/control_ids.h>
|
#include <libcamera/control_ids.h>
|
||||||
#include <libcamera/controls.h>
|
#include <libcamera/controls.h>
|
||||||
#include <libcamera/geometry.h>
|
#include <libcamera/geometry.h>
|
||||||
|
#include <libcamera/orientation.h>
|
||||||
#include <libcamera/transform.h>
|
#include <libcamera/transform.h>
|
||||||
|
|
||||||
#include <libcamera/ipa/core_ipa_interface.h>
|
#include <libcamera/ipa/core_ipa_interface.h>
|
||||||
|
@ -114,7 +115,7 @@ private:
|
||||||
Rectangle activeArea_;
|
Rectangle activeArea_;
|
||||||
const BayerFormat *bayerFormat_;
|
const BayerFormat *bayerFormat_;
|
||||||
bool supportFlips_;
|
bool supportFlips_;
|
||||||
Transform rotationTransform_;
|
Orientation mountingOrientation_;
|
||||||
|
|
||||||
ControlList properties_;
|
ControlList properties_;
|
||||||
|
|
||||||
|
|
|
@ -470,12 +470,12 @@ int CameraSensor::initProperties()
|
||||||
* rotation for later use in computeTransform().
|
* rotation for later use in computeTransform().
|
||||||
*/
|
*/
|
||||||
bool success;
|
bool success;
|
||||||
rotationTransform_ = transformFromRotation(propertyValue, &success);
|
mountingOrientation_ = orientationFromRotation(propertyValue, &success);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
LOG(CameraSensor, Warning)
|
LOG(CameraSensor, Warning)
|
||||||
<< "Invalid rotation of " << propertyValue
|
<< "Invalid rotation of " << propertyValue
|
||||||
<< " degrees - ignoring";
|
<< " degrees - ignoring";
|
||||||
rotationTransform_ = Transform::Identity;
|
mountingOrientation_ = Orientation::Rotate0;
|
||||||
}
|
}
|
||||||
|
|
||||||
properties_.set(properties::Rotation, propertyValue);
|
properties_.set(properties::Rotation, propertyValue);
|
||||||
|
@ -483,7 +483,7 @@ int CameraSensor::initProperties()
|
||||||
LOG(CameraSensor, Warning)
|
LOG(CameraSensor, Warning)
|
||||||
<< "Rotation control not available, default to 0 degrees";
|
<< "Rotation control not available, default to 0 degrees";
|
||||||
properties_.set(properties::Rotation, 0);
|
properties_.set(properties::Rotation, 0);
|
||||||
rotationTransform_ = Transform::Identity;
|
mountingOrientation_ = Orientation::Rotate0;
|
||||||
}
|
}
|
||||||
|
|
||||||
properties_.set(properties::PixelArraySize, pixelArraySize_);
|
properties_.set(properties::PixelArraySize, pixelArraySize_);
|
||||||
|
@ -1137,14 +1137,12 @@ void CameraSensor::updateControlInfo()
|
||||||
*/
|
*/
|
||||||
Transform CameraSensor::computeTransform(Orientation *orientation) const
|
Transform CameraSensor::computeTransform(Orientation *orientation) const
|
||||||
{
|
{
|
||||||
Orientation mountingOrientation = transformToOrientation(rotationTransform_);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we cannot do any flips we cannot change the native camera mounting
|
* If we cannot do any flips we cannot change the native camera mounting
|
||||||
* orientation.
|
* orientation.
|
||||||
*/
|
*/
|
||||||
if (!supportFlips_) {
|
if (!supportFlips_) {
|
||||||
*orientation = mountingOrientation;
|
*orientation = mountingOrientation_;
|
||||||
return Transform::Identity;
|
return Transform::Identity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1153,17 +1151,17 @@ Transform CameraSensor::computeTransform(Orientation *orientation) const
|
||||||
* from the mounting rotation.
|
* from the mounting rotation.
|
||||||
*
|
*
|
||||||
* As a note:
|
* As a note:
|
||||||
* orientation / mountingOrientation = transform
|
* orientation / mountingOrientation_ = transform
|
||||||
* mountingOrientation * transform = orientation
|
* mountingOrientation_ * transform = orientation
|
||||||
*/
|
*/
|
||||||
Transform transform = *orientation / mountingOrientation;
|
Transform transform = *orientation / mountingOrientation_;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If transform contains any Transpose we cannot do it, so adjust
|
* If transform contains any Transpose we cannot do it, so adjust
|
||||||
* 'orientation' to report the image native orientation and return Identity.
|
* 'orientation' to report the image native orientation and return Identity.
|
||||||
*/
|
*/
|
||||||
if (!!(transform & Transform::Transpose)) {
|
if (!!(transform & Transform::Transpose)) {
|
||||||
*orientation = mountingOrientation;
|
*orientation = mountingOrientation_;
|
||||||
return Transform::Identity;
|
return Transform::Identity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue