mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-13 07:19:45 +03:00
libcamera: transform: Invert operator*() operands
The current definition of operator*(Transform t1, Transform t0) follows the function composition notion, where t0 is applied first then t1 is applied last. In order to introduce operator*(Orientation, Transform) where a Transform is applied on top of an Orientation, invert the operand order of operator*(Transform, Transform) so that usage of operator* with both Orientation and Transform can be made associative. For example: Orientation o; Transform t = t1 * t2 Orientation o1 = o * t = o * (t1 * t2) = (o * t1) * t2 = o * t1 * t2 Signed-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
250577878b
commit
b54c935dd7
2 changed files with 13 additions and 13 deletions
|
@ -1136,7 +1136,7 @@ Transform CameraSensor::validateTransform(Transform *transform) const
|
||||||
* Combine the requested transform to compensate the sensor mounting
|
* Combine the requested transform to compensate the sensor mounting
|
||||||
* rotation.
|
* rotation.
|
||||||
*/
|
*/
|
||||||
Transform combined = *transform * rotationTransform_;
|
Transform combined = rotationTransform_ * *transform;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We combine the platform and user transform, but must "adjust away"
|
* We combine the platform and user transform, but must "adjust away"
|
||||||
|
@ -1165,7 +1165,7 @@ Transform CameraSensor::validateTransform(Transform *transform) const
|
||||||
* If the sensor can do no transforms, then combined must be
|
* If the sensor can do no transforms, then combined must be
|
||||||
* changed to the identity. The only user transform that gives
|
* changed to the identity. The only user transform that gives
|
||||||
* rise to this is the inverse of the rotation. (Recall that
|
* rise to this is the inverse of the rotation. (Recall that
|
||||||
* combined = transform * rotationTransform.)
|
* combined = rotationTransform * transform.)
|
||||||
*/
|
*/
|
||||||
*transform = -rotationTransform_;
|
*transform = -rotationTransform_;
|
||||||
combined = Transform::Identity;
|
combined = Transform::Identity;
|
||||||
|
|
|
@ -189,24 +189,24 @@ Input image | | goes to output image | |
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Compose two transforms together
|
* \brief Compose two transforms by applying \a t0 first then \a t1
|
||||||
* \param[in] t1 The second transform
|
* \param[in] t0 The first transform to apply
|
||||||
* \param[in] t0 The first transform
|
* \param[in] t1 The second transform to apply
|
||||||
*
|
*
|
||||||
* Composing transforms follows the usual mathematical convention for
|
* Compose two transforms into a transform that is equivalent to first applying
|
||||||
* composing functions. That is, when performing `t1 * t0`, \a t0 is applied
|
* \a t0 and then applying \a t1. For example, `HFlip * Transpose` performs
|
||||||
* first, and then \a t1.
|
* `HFlip` first and then the `Transpose` yielding `Rot270`, as shown below.
|
||||||
* For example, `Transpose * HFlip` performs `HFlip` first and then the
|
|
||||||
* `Transpose` yielding `Rot270`, as shown below.
|
|
||||||
~~~
|
~~~
|
||||||
A-B B-A B-D
|
A-B B-A B-D
|
||||||
Input image | | -> HFLip -> | | -> Transpose -> | | = Rot270
|
Input image | | -> HFLip -> | | -> Transpose -> | | = Rot270
|
||||||
C-D D-C A-C
|
C-D D-C A-C
|
||||||
~~~
|
~~~
|
||||||
* Note that composition is generally non-commutative for Transforms,
|
* Note that composition is generally non-commutative for Transforms, and not
|
||||||
* and not the same as XOR-ing the underlying bit representations.
|
* the same as XOR-ing the underlying bit representations.
|
||||||
|
*
|
||||||
|
* \return A Transform equivalent to applying \a t0 and then \a t1
|
||||||
*/
|
*/
|
||||||
Transform operator*(Transform t1, Transform t0)
|
Transform operator*(Transform t0, Transform t1)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Reorder the operations so that we imagine doing t0's transpose
|
* Reorder the operations so that we imagine doing t0's transpose
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue