Ocean
NonLinearOptimizationHomography.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_GEOMETRY_NON_LINEAR_OPTIMIZATION_HOMOGRAPHY_H
9 #define META_OCEAN_GEOMETRY_NON_LINEAR_OPTIMIZATION_HOMOGRAPHY_H
10 
13 
16 
17 namespace Ocean
18 {
19 
20 namespace Geometry
21 {
22 
23 /**
24  * This class implements non linear optimization algorithms for homographies.
25  * @ingroup geometry
26  */
27 class OCEAN_GEOMETRY_EXPORT NonLinearOptimizationHomography : protected NonLinearOptimization
28 {
29  public:
30 
31  /**
32  * Definition of a pair holding to sets of corresponding image points.
33  */
34  typedef std::pair<Vectors2, Vectors2> ImagePointsPair;
35 
36  /**
37  * Definition of a vector holding pairs of corresponding image points.
38  */
39  typedef std::vector<ImagePointsPair> ImagePointsPairs;
40 
41  protected:
42 
43 #ifdef OCEAN_USE_SLOWER_IMPLEMENTATION
44  /**
45  * Forward declaration of a class implementing a data object allowing to optimize a homography.
46  */
47  class HomographyData;
48 #endif
49 
50  /**
51  * Forward declaration of a class implementing a provider allowing to optimize a homography matrix.
52  */
53  class HomographyOptimizationProvider;
54 
55  /**
56  * Forward declaration of a class implementing a provider allowing to optimize a similarity matrix.
57  */
58  class SimilarityOptimizationProvider;
59 
60  /**
61  * Forward declaration of a class implementing a data object allowing to optimize a normalized homography.
62  */
63  class NormalizedHomographyData;
64 
65  /**
66  * Forward declaration of a class implementing a data object allowing to optimize a homography concurrently with a camera profile (without distortion parameters).
67  */
68  class HomographyCameraData;
69 
70  /**
71  * Forward declaration of a class implementing a data object allowing to optimize several homographies concurrently.
72  */
73  class CameraHomographiesData;
74 
75  /**
76  * Forward declaration of a class implementing a data object allowing to optimize a homography concurrently with a camera profile (including distortion parameters).
77  */
78  class DistortionCameraHomographiesData;
79 
80  public:
81 
82  /**
83  * Optimizes the homography defining the transformation between two sets of corresponding image points which are projections of 3D object points (lying on a common plane) and visible in two individual camera frames.
84  * This function can use 8 or 9 parameters to represent the optimization model of the homography.<br>
85  * A homography has 8 degrees of freedom so that 8 model parameters should be the correct choice.<br>
86  * However, due to numerical stability the application of 9 model parameters often provides a more robust/stable solution, especially for image point correspondences with complex distributions/locations.
87  * Beware: In case binary size matters, and in case you know which robust estimator to be used for optimizing the homography, please use the corresponding function using a template-parameter for the estimator.
88  * @param homography Initial homography that will be optimized, rightPoint = homography * leftPoint, must be valid
89  * @param imagePointsLeft Projected 3D plane points visible in the left camera frame
90  * @param imagePointsRight Projected 3D plane points visible in the right camera frame, each point corresponds the one point in the left camera frame
91  * @param correspondences Number given image correspondences, with range [4, infinity)
92  * @param modelParameters The number of parameters defining the model (of the homography) to be optimize, with range [8, 9]
93  * @param optimizedHomography Resulting optimized homography, normalized so that the lower right element of the Homography is 1, rightPoint = optimizedHomography * leftPoint
94  * @param iterations Number of iterations to be applied at most, if no convergence can be reached
95  * @param estimator The robust error estimator to be used for calculating the accuracy/error of a homography
96  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
97  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
98  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
99  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
100  * @param invertedCovariances Optional set of 2x2 inverted covariance matrices that represent the uncertainties of the image points (a 2*n x 2 matrix)
101  * @param intermediates Optional resulting intermediate (improving) errors in relation to the defined estimator
102  * @return True, if the homography could be optimized (at least within one iteration)
103  * @see optimizeHomography<tEstimator>().
104  */
105  static bool optimizeHomography(const SquareMatrix3& homography, const Vector2* imagePointsLeft, const Vector2* imagePointsRight, const size_t correspondences, const unsigned int modelParameters, SquareMatrix3& optimizedHomography, const unsigned int iterations = 20u, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), Scalar* initialError = nullptr, Scalar* finalError = nullptr, const Matrix* invertedCovariances = nullptr, Scalars* intermediates = nullptr);
106 
107  /**
108  * Optimizes the homography defining the transformation between two sets of corresponding image points which are projections of 3D object points (lying on a common plane) and visible in two individual camera frames.
109  * This function can use 8 or 9 parameters to represent the optimization model of the homography.<br>
110  * A homography has 8 degrees of freedom so that 8 model parameters should be the correct choice.<br>
111  * However, due to numerical stability the application of 9 model parameters often provides a more robust/stable solution, especially for image point correspondences with complex distributions/locations.
112  * @param homography Initial homography that will be optimized, rightPoint = homography * leftPoint, must be valid
113  * @param imagePointsLeft Projected 3D plane points visible in the left camera frame
114  * @param imagePointsRight Projected 3D plane points visible in the right camera frame, each point corresponds the one point in the left camera frame
115  * @param correspondences Number given image correspondences, with range [4, infinity)
116  * @param modelParameters The number of parameters defining the model (of the homography) to be optimize, with range [8, 9]
117  * @param optimizedHomography Resulting optimized homography, normalized so that the lower right element of the Homography is 1, rightPoint = optimizedHomography * leftPoint
118  * @param iterations Number of iterations to be applied at most, if no convergence can be reached
119  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
120  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
121  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
122  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
123  * @param invertedCovariances Optional set of 2x2 inverted covariance matrices that represent the uncertainties of the image points (a 2*n x 2 matrix)
124  * @param intermediates Optional resulting intermediate (improving) errors in relation to the defined estimator
125  * @return True, if the homography could be optimized (at least within one iteration)
126  * @tparam tEstimator The robust error estimator to be used for calculating the accuracy/error of a homography
127  * @see optimizeHomography().
128  */
129  template <Estimator::EstimatorType tEstimator>
130  static bool optimizeHomography(const SquareMatrix3& homography, const Vector2* imagePointsLeft, const Vector2* imagePointsRight, const size_t correspondences, const unsigned int modelParameters, SquareMatrix3& optimizedHomography, const unsigned int iterations = 20u, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), Scalar* initialError = nullptr, Scalar* finalError = nullptr, const Matrix* invertedCovariances = nullptr, Scalars* intermediates = nullptr);
131 
132  /**
133  * Optimizes a similarity transformation defining the transformation between two sets of corresponding image points visible in two individual camera frames.
134  * Beware: In case binary size matters, and in case you know which robust estimator to be used for optimizing the similarity, please use the corresponding function using a template-parameter for the estimator.
135  * @param similarity Initial similarity that will be optimized, rightPoint = similarity * leftPoint, must be valid
136  * @param imagePointsLeft Projected 3D plane points visible in the left camera frame
137  * @param imagePointsRight Projected 3D plane points visible in the right camera frame, each point corresponds the one point in the left camera frame
138  * @param correspondences Number given image correspondences, with range [2, infinity)
139  * @param optimizedSimilarity Resulting optimized similarity, rightPoint = optimizedSimilarity * leftPoint
140  * @param iterations Number of iterations to be applied at most, if no convergence can be reached
141  * @param estimator The robust error estimator to be used for calculating the accuracy/error of a similarity
142  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
143  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
144  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
145  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
146  * @param invertedCovariances Optional set of 2x2 inverted covariance matrices that represent the uncertainties of the image points (a 2*n x 2 matrix)
147  * @param intermediates Optional resulting intermediate (improving) errors in relation to the defined estimator
148  * @return True, if the similarity could be optimized (at least within one iteration)
149  * @see optimizeSimilarity<tEstimator>().
150  */
151  static bool optimizeSimilarity(const SquareMatrix3& similarity, const Vector2* imagePointsLeft, const Vector2* imagePointsRight, const size_t correspondences, SquareMatrix3& optimizedSimilarity, const unsigned int iterations = 20u, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), Scalar* initialError = nullptr, Scalar* finalError = nullptr, const Matrix* invertedCovariances = nullptr, Scalars* intermediates = nullptr);
152 
153  /**
154  * Optimizes a similarity defining the transformation between two sets of corresponding image points visible in two individual camera frames.
155  * @param similarity Initial similarity that will be optimized, rightPoint = similarity * leftPoint, must be valid
156  * @param imagePointsLeft Projected 3D plane points visible in the left camera frame
157  * @param imagePointsRight Projected 3D plane points visible in the right camera frame, each point corresponds the one point in the left camera frame
158  * @param correspondences Number given image correspondences, with range [2, infinity)
159  * @param optimizedSimilarity Resulting optimized similarity, rightPoint = optimizedSimilarity * leftPoint
160  * @param iterations Number of iterations to be applied at most, if no convergence can be reached
161  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
162  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
163  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
164  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
165  * @param invertedCovariances Optional set of 2x2 inverted covariance matrices that represent the uncertainties of the image points (a 2*n x 2 matrix)
166  * @param intermediates Optional resulting intermediate (improving) errors in relation to the defined estimator
167  * @return True, if the similarity could be optimized (at least within one iteration)
168  * @tparam tEstimator The robust error estimator to be used for calculating the accuracy/error of a similarity
169  * @see optimizeSimilarity().
170  */
171  template <Estimator::EstimatorType tEstimator>
172  static bool optimizeSimilarity(const SquareMatrix3& similarity, const Vector2* imagePointsLeft, const Vector2* imagePointsRight, const size_t correspondences, SquareMatrix3& optimizedSimilarity, const unsigned int iterations = 20u, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), Scalar* initialError = nullptr, Scalar* finalError = nullptr, const Matrix* invertedCovariances = nullptr, Scalars* intermediates = nullptr);
173 
174 #ifdef OCEAN_USE_SLOWER_IMPLEMENTATION
175  /**
176  * Optimizes the planar homography defining the transformation between projected 3D plane points in two cameras frames.
177  * @param homography Initial homography that will be optimized, rightPoint = homography * leftPoint, must be valid
178  * @param imagePointsLeft Projected 3D plane points visible in the left camera frame
179  * @param imagePointsRight Projected 3D plane points visible in the right camera frame, each point corresponds the one point in the left camera frame
180  * @param correspondences Number given image correspondences
181  * @param optimizedHomography Resulting optimized homography, rightPoint = optimizedHomography * leftPoint, must be valid
182  * @param iterations Number of iterations to be applied at most, if no convergence can be reached
183  * @param estimator Robust error estimator to be used
184  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
185  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
186  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
187  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
188  * @return Result of the optimization
189  */
190  static bool optimizeHomography(const SquareMatrix3& homography, const Vector2* imagePointsLeft, const Vector2* imagePointsRight, const size_t correspondences, SquareMatrix3& optimizedHomography, const unsigned int iterations = 20u, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), Scalar* initialError = nullptr, Scalar* finalError = nullptr);
191 #endif
192 
193  /**
194  * Optimizes homography defining the transformation between projected 3D plane points in two cameras frames.
195  * @param pinholeCamera The pinhole camera profile defining the projection, must be valid
196  * @param homography Initial homography that will be optimized, rightPoint = homography * leftPoint, must be valid
197  * @param imagePointsLeft Projected 3D plane points visible in the left camera frame
198  * @param imagePointsRight Projected 3D plane points visible in the right camera frame, each point corresponds the one point in the left camera frame
199  * @param correspondences Number given image correspondences
200  * @param optimizedHomography Resulting optimized homography, rightPoint = optimizedHomography * leftPoint
201  * @param iterations Number of iterations to be applied at most, if no convergence can be reached
202  * @param estimator Robust error estimator to be used
203  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
204  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
205  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
206  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
207  * @return Result of the optimization
208  */
209  static bool optimizeHomography(const PinholeCamera& pinholeCamera, const SquareMatrix3& homography, const Vector2* imagePointsLeft, const Vector2* imagePointsRight, const size_t correspondences, SquareMatrix3& optimizedHomography, const unsigned int iterations = 20u, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), Scalar* initialError = nullptr, Scalar* finalError = nullptr);
210 
211  /**
212  * **TODO** seems to be not correct **TODO** **VALIDATE**
213  * Optimizes the camera profile and the planar homography defining the transformation between projected 3D plane points in two cameras frames.
214  * @param pinholeCamera The initial pinhole camera profile
215  * @param homography Initial homography that will be optimized
216  * @param imagePointsLeft Projected 3D plane points visible in the left camera frame
217  * @param imagePointsRight Projected 3D plane points visible in the right camera frame, each point corresponds the one point in the left camera frame
218  * @param correspondences Number given image correspondences
219  * @param optimizedCamera Optimized camera profile
220  * @param optimizedHomography Resulting optimized homography
221  * @param iterations Number of iterations to be applied at most, if no convergence can be reached
222  * @param estimator Robust error estimator to be used
223  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
224  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
225  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
226  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
227  * @return True, if succeeded
228  */
229  static bool optimizeCameraHomography(const PinholeCamera& pinholeCamera, const SquareMatrix3& homography, const Vector2* imagePointsLeft, const Vector2* imagePointsRight, const size_t correspondences, PinholeCamera& optimizedCamera, SquareMatrix3& optimizedHomography, const unsigned int iterations = 20u, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), Scalar* initialError = nullptr, Scalar* finalError = nullptr);
230 
231  /**
232  * Optimizes the camera profile and concurrently a set of homographies which come with corresponding pairs of image point correspondences.
233  * The given homographies transform image points defined in the 'first' camera frame into image points defined in the 'second' camera frame: p_second = H * p_first.<br>
234  * However, as more than one homography can be provided, each individual homography has an individual 'first' and 'second' camera frame.<br>
235  * The given pairs of points correspondences define the points in the 'first' camera frame (pair.first) and the corresponding points in the 'second' camera frame (pair.second).<br>
236  * @param pinholeCamera The pinhole camera profile that has been used to create the initial homographies
237  * @param homographies The individual homographies each defines a transformation between two camera frames, the number of homographies must match the number of pairs of image point correspondences
238  * @param imagePointsPairs The individual pairs of image points correspondences, each paint pair corresponds with one homography
239  * @param optimizedCamera The resulting optimized camera profile
240  * @param optimizedHomographies The set of optimized homographies
241  * @param iterations Number of iterations to be applied at most, if no convergence can be reached
242  * @param estimator Robust error estimator to be used
243  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
244  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
245  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
246  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
247  * @return True, if succeeded
248  * @see optimizeDistortionCameraHomographies().
249  */
250  static bool optimizeCameraHomographies(const PinholeCamera& pinholeCamera, const SquareMatrices3& homographies, const ImagePointsPairs& imagePointsPairs, PinholeCamera& optimizedCamera, SquareMatrices3& optimizedHomographies, const unsigned int iterations = 20u, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), Scalar* initialError = nullptr, Scalar* finalError = nullptr);
251 
252  /**
253  * Optimizes only the distortion parameters of a camera profile and concurrently a set of homographies which come with corresponding pairs of image point correspondences.
254  * The given homographies transform image points defined in the 'first' camera frame into image points defined in the 'second' camera frame: p_second = H * p_first.<br>
255  * However, as more than one homography can be provided, each individual homography has an individual 'first' and 'second' camera frame.<br>
256  * The given pairs of points correspondences define the points in the 'first' camera frame (pair.first) and the corresponding points in the 'second' camera frame (pair.second).<br>
257  * @param pinholeCamera The pinhole camera profile that has been used to create the initial homographies
258  * @param homographies The individual homographies each defines a transformation between two camera frames, the number of homographies must match the number of pairs of image point correspondences
259  * @param imagePointsPairs The individual pairs of image points correspondences, each paint pair corresponds with one homography
260  * @param optimizedCamera The resulting optimized camera profile
261  * @param optimizedHomographies The set of optimized homographies
262  * @param iterations Number of iterations to be applied at most, if no convergence can be reached
263  * @param estimator Robust error estimator to be used
264  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
265  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
266  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
267  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
268  * @return True, if succeeded
269  * @see optimizeCameraHomographies().
270  */
271  static bool optimizeDistortionCameraHomographies(const PinholeCamera& pinholeCamera, const SquareMatrices3& homographies, const ImagePointsPairs& imagePointsPairs, PinholeCamera& optimizedCamera, SquareMatrices3& optimizedHomographies, const unsigned int iterations = 20u, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), Scalar* initialError = nullptr, Scalar* finalError = nullptr);
272 };
273 
274 }
275 
276 }
277 
278 #endif // META_OCEAN_GEOMETRY_NON_LINEAR_OPTIMIZATION_HOMOGRAPHY_H
EstimatorType
Definition of individual robust estimator types.
Definition: Estimator.h:34
@ ET_SQUARE
The standard square error estimator (L2).
Definition: Estimator.h:52
This class implements non linear optimization algorithms for homographies.
Definition: NonLinearOptimizationHomography.h:28
static bool optimizeDistortionCameraHomographies(const PinholeCamera &pinholeCamera, const SquareMatrices3 &homographies, const ImagePointsPairs &imagePointsPairs, PinholeCamera &optimizedCamera, SquareMatrices3 &optimizedHomographies, const unsigned int iterations=20u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr)
Optimizes only the distortion parameters of a camera profile and concurrently a set of homographies w...
static bool optimizeHomography(const SquareMatrix3 &homography, const Vector2 *imagePointsLeft, const Vector2 *imagePointsRight, const size_t correspondences, const unsigned int modelParameters, SquareMatrix3 &optimizedHomography, const unsigned int iterations=20u, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr, const Matrix *invertedCovariances=nullptr, Scalars *intermediates=nullptr)
Optimizes the homography defining the transformation between two sets of corresponding image points w...
std::vector< ImagePointsPair > ImagePointsPairs
Definition of a vector holding pairs of corresponding image points.
Definition: NonLinearOptimizationHomography.h:39
static bool optimizeHomography(const SquareMatrix3 &homography, const Vector2 *imagePointsLeft, const Vector2 *imagePointsRight, const size_t correspondences, const unsigned int modelParameters, SquareMatrix3 &optimizedHomography, const unsigned int iterations=20u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr, const Matrix *invertedCovariances=nullptr, Scalars *intermediates=nullptr)
Optimizes the homography defining the transformation between two sets of corresponding image points w...
static bool optimizeHomography(const SquareMatrix3 &homography, const Vector2 *imagePointsLeft, const Vector2 *imagePointsRight, const size_t correspondences, SquareMatrix3 &optimizedHomography, const unsigned int iterations=20u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr)
Optimizes the planar homography defining the transformation between projected 3D plane points in two ...
static bool optimizeSimilarity(const SquareMatrix3 &similarity, const Vector2 *imagePointsLeft, const Vector2 *imagePointsRight, const size_t correspondences, SquareMatrix3 &optimizedSimilarity, const unsigned int iterations=20u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr, const Matrix *invertedCovariances=nullptr, Scalars *intermediates=nullptr)
Optimizes a similarity transformation defining the transformation between two sets of corresponding i...
static bool optimizeCameraHomographies(const PinholeCamera &pinholeCamera, const SquareMatrices3 &homographies, const ImagePointsPairs &imagePointsPairs, PinholeCamera &optimizedCamera, SquareMatrices3 &optimizedHomographies, const unsigned int iterations=20u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr)
Optimizes the camera profile and concurrently a set of homographies which come with corresponding pai...
static bool optimizeCameraHomography(const PinholeCamera &pinholeCamera, const SquareMatrix3 &homography, const Vector2 *imagePointsLeft, const Vector2 *imagePointsRight, const size_t correspondences, PinholeCamera &optimizedCamera, SquareMatrix3 &optimizedHomography, const unsigned int iterations=20u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr)
TODO seems to be not correct TODO VALIDATE Optimizes the camera profile and the planar homography def...
static bool optimizeHomography(const PinholeCamera &pinholeCamera, const SquareMatrix3 &homography, const Vector2 *imagePointsLeft, const Vector2 *imagePointsRight, const size_t correspondences, SquareMatrix3 &optimizedHomography, const unsigned int iterations=20u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr)
Optimizes homography defining the transformation between projected 3D plane points in two cameras fra...
static bool optimizeSimilarity(const SquareMatrix3 &similarity, const Vector2 *imagePointsLeft, const Vector2 *imagePointsRight, const size_t correspondences, SquareMatrix3 &optimizedSimilarity, const unsigned int iterations=20u, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr, const Matrix *invertedCovariances=nullptr, Scalars *intermediates=nullptr)
Optimizes a similarity defining the transformation between two sets of corresponding image points vis...
std::pair< Vectors2, Vectors2 > ImagePointsPair
Definition of a pair holding to sets of corresponding image points.
Definition: NonLinearOptimizationHomography.h:34
This class implements the basic functions for least square or robust optimization algorithms for non ...
Definition: NonLinearOptimization.h:34
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::vector< Scalar > Scalars
Definition of a vector holding Scalar objects.
Definition: Math.h:144
std::vector< SquareMatrix3 > SquareMatrices3
Definition of a vector holding SquareMatrix3 objects.
Definition: SquareMatrix3.h:71
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15