Ocean
TestRANSAC.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_TESTGEOMETRY_TEST_RANSAC_H
9 #define META_OCEAN_TEST_TESTGEOMETRY_TEST_RANSAC_H
10 
12 
13 #include "ocean/math/AnyCamera.h"
14 
15 namespace Ocean
16 {
17 
18 namespace Test
19 {
20 
21 namespace TestGeometry
22 {
23 
24 /**
25  * This class implements the tests for RANSAC functions.
26  * @ingroup testgeometry
27  */
28 class OCEAN_TEST_GEOMETRY_EXPORT TestRANSAC
29 {
30  protected:
31 
32  /**
33  * Definition of individual camera distortion types.
34  */
35  enum DistortionType : uint32_t
36  {
37  /// No distortion.
38  DT_NO_DISTORTION = 0u,
39  /// The camera has radial distortion.
40  DT_RADIAL_DISTORTION = 1u << 0u | DT_NO_DISTORTION,
41  /// The camera has full distortion (e.g., radial and tangential).
42  DT_FULL_DISTORTION = (1u << 1u) | DT_RADIAL_DISTORTION
43  };
44 
45  public:
46 
47  /**
48  * Invokes all RANSAC tests.
49  * @param testDuration Number of seconds for each test, with range (0, infinity)
50  * @param worker Optional worker object
51  * @return True, if the entire function test has succeeded
52  */
53  static bool test(const double testDuration, Worker& worker);
54 
55  /**
56  * Tests the iterations function.
57  * @param testDuration Number of seconds for each test, with range (0, infinity)
58  * @return True, if succeeded
59  */
60  static bool testIterations(const double testDuration);
61 
62  /**
63  * Tests the perspective pose function p3p for mono cameras.
64  * @param testDuration Number of seconds for each test, with range (0, infinity)
65  * @return True, if succeeded
66  */
67  static bool testP3P(const double testDuration);
68 
69  /**
70  * Tests the perspective pose function p3p for mono cameras.
71  * @param anyCameraType The camera type to be tested
72  * @param correspondences The number of correspondences to use, with range [4, infinity)
73  * @param faultyRate The rate of invalid correspondences, with range [0, 1)
74  * @param testDuration Number of seconds for each test, with range (0, infinity)
75  * @return True, if succeeded
76  */
77  static bool testP3P(const AnyCameraType anyCameraType, const size_t correspondences, const double faultyRate, const double testDuration);
78 
79  /**
80  * Tests the RANSAC implementation of the perspective pose problem for three random points including unknown zoom factor.
81  * @param testDuration Number of seconds for each test, with range (0, infinity)
82  * @return True, if succeeded
83  */
84  static bool testP3PZoom(const double testDuration);
85 
86  /**
87  * Tests the determination of a 6-DOF object transformation with any stereo camera.
88  * @param testDuration Number of seconds for each test, with range (0, infinity)
89  * @return True, if succeeded
90  */
91  static bool testObjectTransformationStereoAnyCamera(const double testDuration);
92 
93  /**
94  * Tests the RANSAC-based function determining the homography matrix.
95  * @param testDuration Number of seconds for each test, with range (0, infinity)
96  * @param worker The worker object to distribute the computation
97  * @return True, if succeeded
98  */
99  static bool testHomographyMatrix(const double testDuration, Worker& worker);
100 
101  /**
102  * Tests the RANSAC-based function determining the homography matrix with a specified number of point correspondences.
103  * @param testDuration Number of seconds for each test, with range (0, infinity)
104  * @param refine True, to apply an successive non-linear optimization step; False, to keep the internal RANSAC result
105  * @param useSVD True, to use the slower SVD approach (i.e., homographyMatrixSVD); False, to use the two-step approach (i.e., homographyMatrixLinear)
106  * @param worker The worker object to distribute the computation
107  * @return True, if succeeded
108  */
109  static bool testHomographyMatrix(const double testDuration, const bool refine, const bool useSVD, Worker& worker);
110 
111  /**
112  * Tests the RANSAC-based function determining the homography matrix for non-bijective correspondences.
113  * @param testDuration Number of seconds for each test, with range (0, infinity)
114  * @param worker The worker object to distribute the computation
115  * @return True, if succeeded
116  */
117  static bool testHomographyMatrixForNonBijectiveCorrespondences(const double testDuration, Worker& worker);
118 
119  /**
120  * Tests the RANSAC-based function determining the homography matrix with a specified number of non-bijective point correspondences.
121  * @param testDuration Number of seconds for each test, with range (0, infinity)
122  * @param refine True, to apply an successive non-linear optimization step; False, to keep the internal RANSAC result
123  * @param useSVD True, to use the slower SVD approach (i.e., homographyMatrixSVD); False, to use the two-step approach (i.e., homographyMatrixLinear)
124  * @param worker The worker object to distribute the computation
125  * @return True, if succeeded
126  */
127  static bool testHomographyMatrixForNonBijectiveCorrespondences(const double testDuration, const bool refine, const bool useSVD, Worker& worker);
128 };
129 
130 }
131 
132 }
133 
134 }
135 
136 #endif // META_OCEAN_TEST_TESTGEOMETRY_TEST_RANSAC_H
This class implements the tests for RANSAC functions.
Definition: TestRANSAC.h:29
static bool testP3P(const double testDuration)
Tests the perspective pose function p3p for mono cameras.
static bool testHomographyMatrixForNonBijectiveCorrespondences(const double testDuration, Worker &worker)
Tests the RANSAC-based function determining the homography matrix for non-bijective correspondences.
static bool testObjectTransformationStereoAnyCamera(const double testDuration)
Tests the determination of a 6-DOF object transformation with any stereo camera.
static bool test(const double testDuration, Worker &worker)
Invokes all RANSAC tests.
static bool testHomographyMatrixForNonBijectiveCorrespondences(const double testDuration, const bool refine, const bool useSVD, Worker &worker)
Tests the RANSAC-based function determining the homography matrix with a specified number of non-bije...
static bool testHomographyMatrix(const double testDuration, const bool refine, const bool useSVD, Worker &worker)
Tests the RANSAC-based function determining the homography matrix with a specified number of point co...
static bool testIterations(const double testDuration)
Tests the iterations function.
DistortionType
Definition of individual camera distortion types.
Definition: TestRANSAC.h:36
static bool testP3PZoom(const double testDuration)
Tests the RANSAC implementation of the perspective pose problem for three random points including unk...
static bool testHomographyMatrix(const double testDuration, Worker &worker)
Tests the RANSAC-based function determining the homography matrix.
static bool testP3P(const AnyCameraType anyCameraType, const size_t correspondences, const double faultyRate, const double testDuration)
Tests the perspective pose function p3p for mono cameras.
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
AnyCameraType
Definition of individual camera types.
Definition: AnyCamera.h:111
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15