Ocean
TestNonLinearOptimizationHomography.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_NON_LINEAR_OPTIMIZATION_HOMOGRAPHY_H
9 #define META_OCEAN_TEST_TESTGEOMETRY_TEST_NON_LINEAR_OPTIMIZATION_HOMOGRAPHY_H
10 
12 
14 
15 namespace Ocean
16 {
17 
18 namespace Test
19 {
20 
21 namespace TestGeometry
22 {
23 
24 /**
25  * This class implements the tests of the non linear optimization functions for homography optimization.
26  * @ingroup testgeometry
27  */
28 class OCEAN_TEST_GEOMETRY_EXPORT TestNonLinearOptimizationHomography
29 {
30  public:
31 
32  /**
33  * Tests the non linear optimization function.
34  * @param testDuration Number of seconds for each test, with range (0, infinity)
35  * @param worker Optional worker object
36  * @return True, if the entire function test has succeeded
37  */
38  static bool test(const double testDuration, Worker* worker);
39 
40  /**
41  * Tests the non linear optimization function optimizing a homography.
42  * @param testDuration Number of seconds for each test, with range (0, infinity)
43  * @return True, if succeeded
44  */
45  static bool testNonLinearOptimizationHomography(const double testDuration);
46 
47  /**
48  * Tests the non linear optimization function optimizing a similarity transformation.
49  * @param testDuration Number of seconds for each test, with range (0, infinity)
50  * @return True, if succeeded
51  */
52  static bool testNonLinearOptimizationSimilarity(const double testDuration);
53 
54  /**
55  * Tests the non linear optimizations function optimizing a homography with specified correspondences, estimator type and outliers.
56  * @param correspondences Number of point correspondences
57  * @param modelParameter The number of parameters defining the model (of the homography) to be optimize, with range [8, 9]
58  * @param testDuration Number of seconds for each test, with range (0, infinity)
59  * @param type Estimator type to be used
60  * @param standardDeviation Optional standard deviation of the Gaussian distribution for noised image points
61  * @param outliers Number of outlier correspondences
62  * @param useCovariances True, to use covariances
63  * @return True, if succeeded
64  */
65  static bool testNonLinearOptimizationHomography(const unsigned int correspondences, const unsigned int modelParameter, const double testDuration, const Geometry::Estimator::EstimatorType type, const Scalar standardDeviation, const unsigned int outliers, const bool useCovariances);
66 
67  /**
68  * Tests the non linear optimizations function optimizing a similarity transformation with specified correspondences, estimator type and outliers.
69  * @param correspondences Number of point correspondences
70  * @param testDuration Number of seconds for each test, with range (0, infinity)
71  * @param type Estimator type to be used
72  * @param standardDeviation Optional standard deviation of the Gaussian distribution for noised image points
73  * @param outliers Number of outlier correspondences
74  * @param useCovariances True, to use covariances
75  * @return True, if succeeded
76  */
77  static bool testNonLinearOptimizationSimilarity(const unsigned int correspondences, const double testDuration, const Geometry::Estimator::EstimatorType type, const Scalar standardDeviation, const unsigned int outliers, const bool useCovariances);
78 
79  protected:
80 
81  /**
82  * Determines the average pixel error between set of left points transform to the right points.
83  * @param homography The homography that will be checked transforming left points to right points (right = homography * left), must be valid
84  * @param pointsLeft Image points defined in the left camera frame
85  * @param pointsRight Image points defined int he right camerea frame, each point corresponds the one point in the left camera frame
86  * @param maximalSqrDistance Optional resulting maximal square distance between a right image point and the corresponding transformed left image point
87  * @return The average square distance between the right image points and the transformed left image points in pixel, with range [0, infinity)
88  */
89  static Scalar determineHomographyError(const SquareMatrix3& homography, const Vectors2& pointsLeft, const Vectors2& pointsRight, Scalar* maximalSqrDistance = nullptr);
90 };
91 
92 }
93 
94 }
95 
96 }
97 
98 #endif // META_OCEAN_TEST_TESTGEOMETRY_TEST_NON_LINEAR_OPTIMIZATION_HOMOGRAPHY_H
EstimatorType
Definition of individual robust estimator types.
Definition: Estimator.h:34
This class implements the tests of the non linear optimization functions for homography optimization.
Definition: TestNonLinearOptimizationHomography.h:29
static bool testNonLinearOptimizationSimilarity(const double testDuration)
Tests the non linear optimization function optimizing a similarity transformation.
static bool testNonLinearOptimizationSimilarity(const unsigned int correspondences, const double testDuration, const Geometry::Estimator::EstimatorType type, const Scalar standardDeviation, const unsigned int outliers, const bool useCovariances)
Tests the non linear optimizations function optimizing a similarity transformation with specified cor...
static bool testNonLinearOptimizationHomography(const double testDuration)
Tests the non linear optimization function optimizing a homography.
static bool test(const double testDuration, Worker *worker)
Tests the non linear optimization function.
static Scalar determineHomographyError(const SquareMatrix3 &homography, const Vectors2 &pointsLeft, const Vectors2 &pointsRight, Scalar *maximalSqrDistance=nullptr)
Determines the average pixel error between set of left points transform to the right points.
static bool testNonLinearOptimizationHomography(const unsigned int correspondences, const unsigned int modelParameter, const double testDuration, const Geometry::Estimator::EstimatorType type, const Scalar standardDeviation, const unsigned int outliers, const bool useCovariances)
Tests the non linear optimizations function optimizing a homography with specified correspondences,...
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15