summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorStefan Klug <stefan.klug@ideasonboard.com>2024-12-16 16:40:43 +0100
committerStefan Klug <stefan.klug@ideasonboard.com>2024-12-17 10:31:44 +0100
commitec097d63ef9064cc495d9126b54dc772e83137d7 (patch)
tree0a7f23e72f6468af617dafc06ff98b556a3385ee /test
parentdb9b6f8e2302842e0bb153f0c9600444a21ef670 (diff)
libcamera: geometry: Add Rectangle::transformedBetween()
Handling cropping and scaling within a complicated pipeline involves transformations of rectangles between different coordinate systems. For example the full input of the dewarper (0,0)/1920x1080 might correspond to the rectangle (0, 243)/2592x1458 in sensor coordinates (of a 2592x1944 sensor). Add a function that allows the transformation of a rectangle defined in one reference frame (dewarper) into the coordinates of a second reference frame (sensor). Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Diffstat (limited to 'test')
-rw-r--r--test/geometry.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/geometry.cpp b/test/geometry.cpp
index 5760fa3c..11df043b 100644
--- a/test/geometry.cpp
+++ b/test/geometry.cpp
@@ -495,6 +495,17 @@ protected:
return TestFail;
}
+ Rectangle f1 = Rectangle(100, 200, 3000, 2000);
+ Rectangle f2 = Rectangle(200, 300, 1500, 1000);
+ /* Bottom right quarter of the corresponding frames. */
+ Rectangle r1 = Rectangle(100 + 1500, 200 + 1000, 1500, 1000);
+ Rectangle r2 = Rectangle(200 + 750, 300 + 500, 750, 500);
+ if (r1.transformedBetween(f1, f2) != r2 ||
+ r2.transformedBetween(f2, f1) != r1) {
+ cout << "Rectangle::transformedBetween() test failed" << endl;
+ return TestFail;
+ }
+
return TestPass;
}
};