Ocean
Loading...
Searching...
No Matches
TestFrameRectification.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_TEST_TESTCV_TESTADVANCED_TEST_FRAME_RECTIFICATION_H
9#define META_OCEAN_TEST_TESTCV_TESTADVANCED_TEST_FRAME_RECTIFICATION_H
10
12
13#include "ocean/base/Frame.h"
14#include "ocean/base/Worker.h"
15
17#include "ocean/math/Box3.h"
19#include "ocean/math/Vector2.h"
20
22
23namespace Ocean
24{
25
26namespace Test
27{
28
29namespace TestCV
30{
31
32namespace TestAdvanced
33{
34
35/**
36 * This class implements a frame rectification test.
37 * @ingroup testcvadvanced
38 */
39class OCEAN_TEST_CV_ADVANCED_EXPORT TestFrameRectification
40{
41 public:
42
43 /**
44 * Tests the frame rectification functions.
45 * @param width The width of the test frame in pixel, with range [1u, infinity)
46 * @param height The height of the test frame in pixel, with range [1, infinity)
47 * @param testDuration The number of seconds for each test, with range (0, infinity)
48 * @param worker The worker object to distribute the computation
49 * @param selector The test selector to filter tests
50 * @return True, if succeeded
51 */
52 static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker, const TestSelector& selector);
53
54 /**
55 * Tests the rectification function for a planar rectangle object.
56 * @param width The width of the test frame in pixel, with range [1u, infinity)
57 * @param height The height of the test frame in pixel, with range [1, infinity)
58 * @param testDuration The number of seconds for each test, with range (0, infinity)
59 * @param worker The worker object to distribute the computation
60 * @return True, if succeeded
61 */
62 static bool testPlanarRectangleObject(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
63
64 /**
65 * Tests the rectification function for an arbitrary rectangle object.
66 * @param width The width of the test frame in pixel, with range [1u, infinity)
67 * @param height The height of the test frame in pixel, with range [1, infinity)
68 * @param testDuration The number of seconds for each test, with range (0, infinity)
69 * @param worker The worker object to distribute the computation
70 * @return True, if succeeded
71 */
72 static bool testArbitraryRectangleObject(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
73
74 /**
75 * Tests the rectification function for triangles.
76 * @param width The width of the test frame in pixel, with range [1u, infinity)
77 * @param height The height of the test frame in pixel, with range [1, infinity)
78 * @param testDuration The number of seconds for each test, with range (0, infinity)
79 * @param worker The worker object to distribute the computation
80 * @return True, if succeeded
81 */
82 static bool testTriangleObject(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
83
84 /**
85 * Tests the mask rectification function for a planar rectangle object.
86 * @param width The width of the test frame in pixel, with range [1u, infinity)
87 * @param height The height of the test frame in pixel, with range [1, infinity)
88 * @param testDuration The number of seconds for each test, with range (0, infinity)
89 * @param worker The worker object to distribute the computation
90 * @return True, if succeeded
91 */
92 static bool testPlanarRectangleObjectMask(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
93
94 /**
95 * Tests the mask rectification function for an arbitrary rectangle object.
96 * @param width The width of the test frame in pixel, with range [1u, infinity)
97 * @param height The height of the test frame in pixel, with range [1, infinity)
98 * @param testDuration The number of seconds for each test, with range (0, infinity)
99 * @param worker The worker object to distribute the computation
100 * @return True, if succeeded
101 */
102 static bool testArbitraryRectangleObjectMask(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
103
104 /**
105 * Tests the mask rectification function for triangles.
106 * @param width The width of the test frame in pixel, with range [1u, infinity)
107 * @param height The height of the test frame in pixel, with range [1, infinity)
108 * @param testDuration The number of seconds for each test, with range (0, infinity)
109 * @param worker The worker object to distribute the computation
110 * @return True, if succeeded
111 */
112 static bool testTriangleObjectMask(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
113
114 protected:
115
116 /**
117 * Determines the average color intensity error between two frames while excluding a two pixel thick border at the frame boundaries.
118 * @param frame0 The first frame to be checked, must be valid
119 * @param frame1 The second frame to be checked, must be valid
120 * @param skipColor0 Optional pixel color to skip error calculation for pixels with this color in the first frame, nullptr otherwise
121 * @param skipColor1 Optional pixel color to skip error calculation for pixels with this color in the second frame, nullptr otherwise
122 * @return The average pixel-wise color difference between both frame
123 */
124 static double determineFrameError(const Frame& frame0, const Frame& frame1, const uint8_t* skipColor0, const uint8_t* skipColor1);
125
126 /**
127 * Renders a planar rectangular object with given camera profile and camera pose.
128 * @param objectFrame The square object frame to be rendered, must be valid
129 * @param targetFrame The resulting rendered frame, must be valid
130 * @param camera The camera profile to be used for rendering
131 * @param world_T_camera The transformation between camera and world, must be valid
132 * @param objectDimension The dimension of the object frame to be rendered, with range (0, infinity)x(0, infinity)
133 * @return True, if succeeded
134 */
135 static bool renderPlanarRectangleObject(const Frame& objectFrame, Frame& targetFrame, const AnyCamera& camera, const HomogenousMatrix4& world_T_camera, const Vector2& objectDimension);
136
137 /**
138 * Determines a camera pose so that all corners of a given bounding box are visible in the camera.
139 * @param camera The camera profile defining the projection, must be valid
140 * @param boundingBox The 3D bounding box, must be valid
141 * @param world_R_camera The rotation of the camera to be used, must be valid
142 * @return The transformation between camera and world (world_T_camera)
143 */
144 static HomogenousMatrix4 determineCameraPose(const AnyCamera& camera, const Box3& boundingBox, const Quaternion& world_R_camera);
145};
146
147}
148
149}
150
151}
152
153}
154
155#endif // META_OCEAN_TEST_TESTCV_TESTADVANCED_TEST_FRAME_RECTIFICATION_H
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:131
This class implements Ocean's image class.
Definition Frame.h:1879
This class implements a frame rectification test.
Definition TestFrameRectification.h:40
static bool renderPlanarRectangleObject(const Frame &objectFrame, Frame &targetFrame, const AnyCamera &camera, const HomogenousMatrix4 &world_T_camera, const Vector2 &objectDimension)
Renders a planar rectangular object with given camera profile and camera pose.
static bool testArbitraryRectangleObject(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the rectification function for an arbitrary rectangle object.
static bool testTriangleObject(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the rectification function for triangles.
static HomogenousMatrix4 determineCameraPose(const AnyCamera &camera, const Box3 &boundingBox, const Quaternion &world_R_camera)
Determines a camera pose so that all corners of a given bounding box are visible in the camera.
static double determineFrameError(const Frame &frame0, const Frame &frame1, const uint8_t *skipColor0, const uint8_t *skipColor1)
Determines the average color intensity error between two frames while excluding a two pixel thick bor...
static bool testPlanarRectangleObjectMask(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the mask rectification function for a planar rectangle object.
static bool testPlanarRectangleObject(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the rectification function for a planar rectangle object.
static bool testTriangleObjectMask(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the mask rectification function for triangles.
static bool testArbitraryRectangleObjectMask(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the mask rectification function for an arbitrary rectangle object.
static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker, const TestSelector &selector)
Tests the frame rectification functions.
This class implements a test selector that parses test function strings and determines which tests sh...
Definition TestSelector.h:51
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
The namespace covering the entire Ocean framework.
Definition Accessor.h:15