Ocean
NonLinearOptimizationObjectPoint.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_OBJECT_POINT_H
9 #define META_OCEAN_GEOMETRY_NON_LINEAR_OPTIMIZATION_OBJECT_POINT_H
10 
13 
14 #include "ocean/math/AnyCamera.h"
19 
20 namespace Ocean
21 {
22 
23 namespace Geometry
24 {
25 
26 /**
27  * This class implements least square or robust optimization algorithms optimizing the locations of 3D object points (sometimes in combination with e.g., 3-DOF camera orientations or 6-DOF camera poses).
28  * Therefore, this class implements typical Bundle Adjustment tasks e.g., for 3D object points and 6-DOF camera poses.
29  * @ingroup geometry
30  */
31 class OCEAN_GEOMETRY_EXPORT NonLinearOptimizationObjectPoint : protected NonLinearOptimization
32 {
33  protected:
34 
35  /**
36  * Definition of a 3x3 matrix.
37  */
39 
40  /**
41  * Definition of a 3x6 matrix.
42  */
44 
45  /**
46  * Definition of a 6x3 matrix.
47  */
49 
50  /**
51  * Definition of a 6x6 matrix.
52  */
54 
55  /**
56  * Definition of a vector holding 3x3 matrices.
57  */
58  typedef std::vector<StaticMatrix3x3> StaticMatrices3x3;
59 
60  /**
61  * Definition of a vector holding 6x3 matrices.
62  */
63  typedef std::vector<StaticMatrix6x3> StaticMatrices6x3;
64 
65  /**
66  * Definition of a vector holding 6x6 matrices.
67  */
68  typedef std::vector<StaticMatrix6x6> StaticMatrices6x6;
69 
70  /**
71  * Forward declaration of a provider object allowing to optimize one object point location for (6DOF) camera poses with any camera.
72  */
73  class CameraObjectPointProvider;
74 
75  /**
76  * Forward declaration of a provider object allowing to optimize one object point location for (6DOF) camera poses with any camera.
77  */
78  class CamerasObjectPointProvider;
79 
80  /**
81  * Forward declaration of a provider object allowing to optimize one object point location for (6DOF) camera poses with any stereo camera.
82  */
83  class StereoCameraObjectPointProvider;
84 
85  /**
86  * Forward declaration of a provider object allowing to optimize one object point location for (3DOF) rotational camera poses.
87  */
88  class SphericalObjectPointProvider;
89 
90  /**
91  * Forward declaration of a data object allowing to optimize object point locations and rotational camera poses.
92  */
93  class ObjectPointsOrientationsData;
94 
95  /**
96  * Forward declaration of a highly optimized provider object allowing to optimize one camera pose and several 3D object point locations concurrently.
97  * @tparam tEstimator The robust estimator to be used as error measure
98  */
99  template <Estimator::EstimatorType tEstimator>
101 
102  /**
103  * Forward declaration of a provider allowing to optimize two camera poses and 3D object point locations concurrently.
104  */
105  class ObjectPointsTwoPosesProvider;
106 
107  /**
108  * Forward declaration of a highly optimized provider object allowing to optimize several camera pose and several 3D object point locations concurrently.
109  * @tparam tEstimator The robust estimator to be used as error measure
110  * @see SlowObjectPointsPosesProvider.
111  */
112  template <Estimator::EstimatorType tEstimator>
114 
115  /**
116  * Forward declaration of a highly optimized provider object allowing to optimize the orientations of several camera pose and several 3D object point locations concurrently.
117  * @tparam tEstimator The robust estimator to be used as error measure
118  * @see SlowObjectPointsPosesProvider.
119  */
120  template <Estimator::EstimatorType tEstimator>
122 
123  /**
124  * Forward declaration of a slow implementation of a provider object allowing to optimize several camera poses and 3D object point locations concurrently.
125  * The implementation is slower than the implementation of ObjectPointsPosesProvider and should not be used in practice.<br>
126  * The code remains for demonstration and evaluation purposes.
127  * @see ObjectPointsPosesProvider.
128  */
129  class SlowObjectPointsPosesProvider;
130 
131  public:
132 
133  /**
134  * Minimizes the projection errors for one given 3D object point, visible in several individual (fixed) camera images, by minimizing the projection error between the 3D object point and the 2D image points.
135  * @param camera The camera profile defining the projection between 3D object points and 2D image points, must be valid
136  * @param world_T_cameras The accessor for 6-DOF camera poses of the camera frames, with default camera pointing towards the negative z-space with y-axis upwards, at least two
137  * @param worldObjectPoint The 3D object point to be projected into the camera plane and for that the projection error is minimized, defined in world
138  * @param imagePoints The accessor for the image points that are visible in individual camera frames (with world_T_cameras.size() == imagePoints.size())
139  * @param optimizedWorldObjectPoint Resulting optimized 3D object point, defined in world
140  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
141  * @param estimator Robust error estimator to be used
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 onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
145  * @param initialRobustError Optional resulting averaged robust pixel error for the given initial parameters
146  * @param finalRobustError Optional resulting averaged robust pixel error for the final optimized parameters
147  * @param intermediateRobustErrors Optional resulting averaged robust pixel errors for intermediate optimization iterations
148  * @return True, if succeeded
149  * @see optimizeObjectPointForFixedPosesIF().
150  */
151  static inline bool optimizeObjectPointForFixedPoses(const AnyCamera& camera, const ConstIndexedAccessor<HomogenousMatrix4>& world_T_cameras, const Vector3& worldObjectPoint, const ConstIndexedAccessor<Vector2>& imagePoints, Vector3& optimizedWorldObjectPoint, const unsigned int iterations = 5u, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = 10, const bool onlyFrontObjectPoints = true, Scalar* initialRobustError = nullptr, Scalar* finalRobustError = nullptr, Scalars* intermediateRobustErrors = nullptr);
152 
153  /**
154  * Minimizes the projection errors for one given 3D object point, visible in several individual (fixed) camera images, by minimizing the projection error between the 3D object point and the 2D image points.
155  * Beware: The given inverted and flipped 6DOF poses are not equivalent to a standard extrinsic camera matrix.<br>
156  * @param camera The camera profile defining the projection between 3D object points and 2D image points, must be valid
157  * @param flippedCameras_T_world The accessor for (inverted and flipped) 6-DOF camera poses of the camera frames, with default flipped camera pointing towards the positive z-space with y-axis downwards, at least two
158  * @param worldObjectPoint The 3D object point to be projected into the camera plane and for that the projection error is minimized, defined in world
159  * @param imagePoints The accessor for the image points that are visible in individual camera frames (with flippedCameras_T_world.size() == imagePoints.size())
160  * @param optimizedWorldObjectPoint Resulting optimized 3D object point, defined in world
161  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
162  * @param estimator Robust error estimator to be used
163  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
164  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
165  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
166  * @param initialRobustError Optional resulting averaged robust pixel error for the given initial parameters
167  * @param finalRobustError Optional resulting averaged robust pixel error for the final optimized parameters
168  * @param intermediateRobustErrors Optional resulting averaged robust pixel errors for intermediate optimization iterations
169  * @return True, if succeeded
170  * @see optimizeObjectPointForFixedPoses().
171  */
172  static bool optimizeObjectPointForFixedPosesIF(const AnyCamera& camera, const ConstIndexedAccessor<HomogenousMatrix4>& flippedCameras_T_world, const Vector3& worldObjectPoint, const ConstIndexedAccessor<Vector2>& imagePoints, Vector3& optimizedWorldObjectPoint, const unsigned int iterations = 5u, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = 10, const bool onlyFrontObjectPoints = true, Scalar* initialRobustError = nullptr, Scalar* finalRobustError = nullptr, Scalars* intermediateRobustErrors = nullptr);
173 
174  /**
175  * Minimizes the projection errors for one given 3D object point, visible in several individual (fixed) camera images, by minimizing the projection error between the 3D object point and the 2D image points.
176  * @param cameras The camera profiles defining the projection between 3D object points and 2D image points, one individual provide for each observation, must be valid
177  * @param world_T_cameras The accessor for 6-DOF camera poses of the camera frames, with default camera pointing towards the negative z-space with y-axis upwards, at least two
178  * @param worldObjectPoint The 3D object point to be projected into the camera plane and for that the projection error is minimized, defined in world
179  * @param imagePoints The accessor for the image points that are visible in individual camera frames (with world_T_cameras.size() == imagePoints.size())
180  * @param optimizedWorldObjectPoint Resulting optimized 3D object point, defined in world
181  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
182  * @param estimator Robust error estimator to be used
183  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
184  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
185  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
186  * @param initialRobustError Optional resulting averaged robust pixel error for the given initial parameters
187  * @param finalRobustError Optional resulting averaged robust pixel error for the final optimized parameters
188  * @param intermediateRobustErrors Optional resulting averaged robust pixel errors for intermediate optimization iterations
189  * @return True, if succeeded
190  * @see optimizeObjectPointForFixedPosesIF().
191  */
192  static inline bool optimizeObjectPointForFixedPoses(const ConstIndexedAccessor<const AnyCamera*>& cameras, const ConstIndexedAccessor<HomogenousMatrix4>& world_T_cameras, const Vector3& worldObjectPoint, const ConstIndexedAccessor<Vector2>& imagePoints, Vector3& optimizedWorldObjectPoint, const unsigned int iterations = 5u, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = 10, const bool onlyFrontObjectPoints = true, Scalar* initialRobustError = nullptr, Scalar* finalRobustError = nullptr, Scalars* intermediateRobustErrors = nullptr);
193 
194  /**
195  * Minimizes the projection errors for one given 3D object point, visible in several individual (fixed) camera images, by minimizing the projection error between the 3D object point and the 2D image points.
196  * Beware: The given inverted and flipped 6DOF poses are not equivalent to a standard extrinsic camera matrix.<br>
197  * @param cameras The camera profiles defining the projection between 3D object points and 2D image points, one individual provide for each observation, must be valid
198  * @param flippedCameras_T_world The accessor for (inverted and flipped) 6-DOF camera poses of the camera frames, with default flipped camera pointing towards the positive z-space with y-axis downwards, at least two
199  * @param worldObjectPoint The 3D object point to be projected into the camera plane and for that the projection error is minimized, defined in world
200  * @param imagePoints The accessor for the image points that are visible in individual camera frames (with flippedCameras_T_world.size() == imagePoints.size())
201  * @param optimizedWorldObjectPoint Resulting optimized 3D object point, defined in world
202  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
203  * @param estimator Robust error estimator to be used
204  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
205  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
206  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
207  * @param initialRobustError Optional resulting averaged robust pixel error for the given initial parameters
208  * @param finalRobustError Optional resulting averaged robust pixel error for the final optimized parameters
209  * @param intermediateRobustErrors Optional resulting averaged robust pixel errors for intermediate optimization iterations
210  * @return True, if succeeded
211  * @see optimizeObjectPointForFixedPoses().
212  */
213  static bool optimizeObjectPointForFixedPosesIF(const ConstIndexedAccessor<const AnyCamera*>& cameras, const ConstIndexedAccessor<HomogenousMatrix4>& flippedCameras_T_world, const Vector3& worldObjectPoint, const ConstIndexedAccessor<Vector2>& imagePoints, Vector3& optimizedWorldObjectPoint, const unsigned int iterations = 5u, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = 10, const bool onlyFrontObjectPoints = true, Scalar* initialRobustError = nullptr, Scalar* finalRobustError = nullptr, Scalars* intermediateRobustErrors = nullptr);
214 
215  /**
216  * Minimizes the projection errors for one given 3D object point, visible in several individual (fixed) stereo fisheye camera frames, by minimizing the projection error between the 3D object point and the 2D image points.
217  * The number of provided observations from the first (e.g., left) stereo camera can be different from the number of observations from the second (e.g., right) stereo camera.
218  * @param anyCameraA The fisheye camera profile of first (e.g., left) stereo images defining the projection between 3D object points and 2D image points, must be valid
219  * @param anyCameraB The fisheye camera profile of second (e.g., right) stereo images defining the projection between 3D object points and 2D image points, must be valid
220  * @param world_T_camerasA The accessor for 6-DOF camera poses of the first stereo camera frames, with `poseAccessor_world_T_cameraA.size() + poseAccessor_world_T_cameraB.size() >= 2`
221  * @param world_T_camerasB The accessor for 6-DOF camera poses of the second stereo camera frames, with `poseAccessor_world_T_cameraA.size() + poseAccessor_world_T_cameraB.size() >= 2`
222  * @param worldObjectPoint The 3D object point to be optimized, defined in world
223  * @param imagePointAccessorA The accessor for the image points that are visible in individual first stereo camera frames (with poseAccessor_world_T_cameraA.size() == imagePointAccessorA.size())
224  * @param imagePointAccessorB The accessor for the image points that are visible in individual second stereo camera frames (with poseAccessor_world_T_cameraB.size() == imagePointAccessorB.size())
225  * @param optimizedWorldObjectPoint Resulting optimized 3D object point, defined in world
226  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
227  * @param estimator Robust error estimator to be used
228  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
229  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
230  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
231  * @param initialRobustError Optional resulting averaged robust pixel error for the given initial parameters
232  * @param finalRobustError Optional resulting averaged robust pixel error for the final optimized parameters
233  * @param intermediateRobustErrors Optional resulting averaged robust pixel errors for intermediate optimization iterations
234  * @return True, if succeeded
235  * @see optimizeObjectPointForFixedPosesIF().
236  */
237  static inline bool optimizeObjectPointForFixedStereoPoses(const AnyCamera& anyCameraA, const AnyCamera& anyCameraB, const ConstIndexedAccessor<HomogenousMatrix4>& world_T_camerasA, const ConstIndexedAccessor<HomogenousMatrix4>& world_T_camerasB, const Vector3& worldObjectPoint, const ConstIndexedAccessor<Vector2>& imagePointAccessorA, const ConstIndexedAccessor<Vector2>& imagePointAccessorB, Vector3& optimizedWorldObjectPoint, const unsigned int iterations = 5u, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = 10, const bool onlyFrontObjectPoints = true, Scalar* initialRobustError = nullptr, Scalar* finalRobustError = nullptr, Scalars* intermediateRobustErrors = nullptr);
238 
239  /**
240  * Minimizes the projection errors for one given 3D object point, visible in several individual (fixed) stereo fisheye camera frames, by minimizing the projection error between the 3D object point and the 2D image points.
241  * The number of provided observations from the first (e.g., left) stereo camera can be different from the number of observations from the second (e.g., right) stereo camera.
242  * Beware: The given inverted and flipped 6DOF poses are not equivalent to a standard extrinsic camera matrix.<br>
243  * @param anyCameraA The fisheye camera profile of first (e.g., left) stereo images defining the projection between 3D object points and 2D image points, must be valid
244  * @param anyCameraB The fisheye camera profile of second (e.g., right) stereo images defining the projection between 3D object points and 2D image points, must be valid
245  * @param flippedCamerasA_T_world The accessor for (inverted and flipped) 6-DOF camera poses of the first stereo camera frames, with `poseAccessor_flippedCameraA_T_world.size() + poseAccessor_flippedCameraB_T_world.size() >= 2`
246  * @param flippedCamerasB_T_world The accessor for (inverted and flipped) 6-DOF camera poses of the second stereo camera frames, with `poseAccessor_flippedCameraA_T_world.size() + poseAccessor_flippedCameraB_T_world.size() >= 2`
247  * @param worldObjectPoint The 3D object point to be optimized, defined in world
248  * @param imagePointAccessorA The accessor for the image points that are visible in individual first stereo camera frames (with poseAccessor_flippedCameraA_T_world.size() == imagePointAccessorA.size())
249  * @param imagePointAccessorB The accessor for the image points that are visible in individual second stereo camera frames (with poseAccessor_flippedCameraB_T_world.size() == imagePointAccessorB.size())
250  * @param optimizedWorldObjectPoint Resulting optimized 3D object point, defined in world
251  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
252  * @param estimator Robust error estimator to be used
253  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
254  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
255  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
256  * @param initialRobustError Optional resulting averaged robust pixel error for the given initial parameters
257  * @param finalRobustError Optional resulting averaged robust pixel error for the final optimized parameters
258  * @param intermediateRobustErrors Optional resulting averaged robust pixel errors for intermediate optimization iterations
259  * @return True, if succeeded
260  * @see optimizeObjectPointForFixedPoses().
261  */
262  static bool optimizeObjectPointForFixedStereoPosesIF(const AnyCamera& anyCameraA, const AnyCamera& anyCameraB, const ConstIndexedAccessor<HomogenousMatrix4>& flippedCamerasA_T_world, const ConstIndexedAccessor<HomogenousMatrix4>& flippedCamerasB_T_world, const Vector3& worldObjectPoint, const ConstIndexedAccessor<Vector2>& imagePointAccessorA, const ConstIndexedAccessor<Vector2>& imagePointAccessorB, Vector3& optimizedWorldObjectPoint, const unsigned int iterations = 5u, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = 10, const bool onlyFrontObjectPoints = true, Scalar* initialRobustError = nullptr, Scalar* finalRobustError = nullptr, Scalars* intermediateRobustErrors = nullptr);
263 
264  /**
265  * Minimizes the projection errors of given 3D object points, visible in several individual (fixed) camera frames, by minimizing the projection error between the 3D object point and the 2D image points.
266  * The given 6DOF poses are standard extrinsic camera matrix.<br>
267  * The number of correspondences can vary between the individual frames (groups).<br>
268  * Each group may address individual object points, however the larger the intersection of sets between the individual 3D object points in the individual frames the better the optimization result.
269  * @param pinholeCamera The pinhole camera object defining the projection between 3D object points and 2D image points
270  * @param poseAccessor The accessor for the known (and fixed) poses of the individual camera frames
271  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points
272  * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
273  * @param distortImagePoints True, to force the usage of the distortion parameters of the given camera object to distort the projected 2D image points before error determination
274  * @param optimizedObjectPoints Accessor for the resulting optimized 3D object points locations
275  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
276  * @param estimator Robust error estimator to be used
277  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
278  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
279  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
280  * @param worker Optional worker object to distribute the computation
281  * @return True, if succeeded
282  * @see optimizeObjectPointsForFixedPosesIF().
283  */
284  static inline bool optimizeObjectPointsForFixedPoses(const PinholeCamera& pinholeCamera, const ConstIndexedAccessor<HomogenousMatrix4>& poseAccessor, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, const bool distortImagePoints, NonconstIndexedAccessor<Vector3>& optimizedObjectPoints, const unsigned int iterations = 5u, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = 10, const bool onlyFrontObjectPoints = true, Worker* worker = nullptr);
285 
286  /**
287  * Minimizes the projection errors of given 3D object points, visible in several individual (fixed) camera frames, by minimizing the projection error between the 3D object point and the 2D image points.
288  * Beware: The given inverted and flipped 6DOF poses are not equivalent to a standard extrinsic camera matrix.<br>
289  * The number of correspondences can vary between the individual frames (groups).<br>
290  * Each group may address individual object points, however the larger the intersection of sets between the individual 3D object points in the individual frames the better the optimization result.
291  * @param pinholeCamera The pinhole camera object defining the projection between 3D object points and 2D image points
292  * @param invertedFlippedPoses The accessor for the known (and fixed) poses of the individual camera frames
293  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points
294  * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
295  * @param distortImagePoints True, to force the usage of the distortion parameters of the given camera object to distort the projected 2D image points before error determination
296  * @param optimizedObjectPoints Accessor for the resulting optimized 3D object points locations
297  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
298  * @param estimator Robust error estimator to be used
299  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
300  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
301  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
302  * @param worker Optional worker object to distribute the computation
303  * @return True, if succeeded
304  * @see optimizeObjectPointsForFixedPoses().
305  */
306  static bool optimizeObjectPointsForFixedPosesIF(const PinholeCamera& pinholeCamera, const ConstIndexedAccessor<HomogenousMatrix4>& invertedFlippedPoses, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, const bool distortImagePoints, NonconstIndexedAccessor<Vector3>& optimizedObjectPoints, const unsigned int iterations = 5u, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = 10, const bool onlyFrontObjectPoints = true, Worker* worker = nullptr);
307 
308  /**
309  * Optimizes the locations of one 3D object point visible in individual (fixed) camera poses all located at the origin with individual orientations by minimizing the projection error between the 3D object point and the 2D image points.
310  * @param camera The camera profile defining the projection, must be valid
311  * @param world_R_cameras The accessor for the orientations of the individual cameras, with default camera pointing towards the negative z-space with y-axis upwards, at least two
312  * @param imagePoints The accessor for the image points which are projections of the 3D object points, one image point for each orientation
313  * @param objectPoint The rough object point location to optimize
314  * @param objectPointDistance The distance between the origin and the 3D object points, with range (0, infinity)
315  * @param optimizedObjectPoint The resulting optimized 3D object points locations
316  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
317  * @param estimator Robust error estimator to be used
318  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
319  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
320  * @param onlyFrontObjectPoint True, to avoid that the optimized 3D position lies behind any camera
321  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
322  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
323  * @param intermediateErrors Optional resulting intermediate (improving) errors
324  * @return True, if succeeded
325  * @see optimizeObjectPointForFixedOrientationsIF().
326  */
327  static inline bool optimizeObjectPointForFixedOrientations(const AnyCamera& camera, const ConstIndexedAccessor<SquareMatrix3>& world_R_cameras, const ConstIndexedAccessor<Vector2>& imagePoints, const Vector3& objectPoint, const Scalar objectPointDistance, Vector3& optimizedObjectPoint, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator = Geometry::Estimator::ET_SQUARE, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), const bool onlyFrontObjectPoint = true, Scalar* initialError = nullptr, Scalar* finalError = nullptr, Scalars* intermediateErrors = nullptr);
328 
329  /**
330  * Optimizes the locations of one 3D object point visible in individual (fixed) camera poses all located at the origin with individual orientations by minimizing the projection error between the 3D object point and the 2D image points.
331  * @param camera The camera profile defining the projection, must be valid
332  * @param flippedCameras_R_world The accessor for the inverted and flipped orientations of the individual cameras, with default flipped camera pointing towards the positive z-space with y-axis downwards, at least two
333  * @param imagePoints The accessor for the image points which are projections of the 3D object points, one image point for each orientation
334  * @param objectPoint The rough object point location to optimize
335  * @param objectPointDistance The distance between the origin and the 3D object points, with range (0, infinity)
336  * @param optimizedObjectPoint The resulting optimized 3D object points locations
337  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
338  * @param estimator Robust error estimator to be used
339  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
340  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
341  * @param onlyFrontObjectPoint True, to avoid that the optimized 3D position lies behind any camera
342  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
343  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
344  * @param intermediateErrors Optional resulting intermediate (improving) errors
345  * @return True, if succeeded
346  * @see optimizeObjectPointForFixedOrientations().
347  */
348  static bool optimizeObjectPointForFixedOrientationsIF(const AnyCamera& camera, const ConstIndexedAccessor<SquareMatrix3>& flippedCameras_R_world, const ConstIndexedAccessor<Vector2>& imagePoints, const Vector3& objectPoint, const Scalar objectPointDistance, Vector3& optimizedObjectPoint, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator = Geometry::Estimator::ET_SQUARE, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), const bool onlyFrontObjectPoint = true, Scalar* initialError = nullptr, Scalar* finalError = nullptr, Scalars* intermediateErrors = nullptr);
349 
350  /**
351  * Optimizes the locations of 3D object points visible in individual camera poses all located at the origin with individual orientations by minimizing the projection error between the 3D object points and the 2D image points.
352  * Further, this function optimized the orientation of the individual camera poses.<br>
353  * The number of correspondences may vary between the individual frames (groups).<br>
354  * Each group may address individual object points, however the larger the intersection of sets between the individual 3D object points in the individual frames the better the optimization result.<br>
355  * @param pinholeCamera The pinhole camera profile defining the projection
356  * @param orientations The accessor for the known (but rough) orientations of the individual camera frames
357  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points
358  * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
359  * @param objectPointDistance The distance between the origin and the 3D object points, with range (0, infinity)
360  * @param optimizedOrientations Optional accessor for the resulting optimized camera orientations, nullptr otherwise
361  * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
362  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
363  * @param estimator Robust error estimator to be used
364  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
365  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
366  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
367  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
368  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
369  * @param intermediateErrors Optional resulting intermediate (improving) errors
370  * @return True, if succeeded
371  */
372  static bool optimizeObjectPointsAndOrientations(const PinholeCamera& pinholeCamera, const ConstIndexedAccessor<SquareMatrix3>& orientations, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, const Scalar objectPointDistance, NonconstIndexedAccessor<SquareMatrix3>* optimizedOrientations, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator = Geometry::Estimator::ET_SQUARE, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), const bool onlyFrontObjectPoints = true, Scalar* initialError = nullptr, Scalar* finalError = nullptr, Scalars* intermediateErrors = nullptr);
373 
374  /**
375  * Optimizes the locations of 3D object points visible in two individual camera poses by minimizing the projection error between the 3D object points and the 2D image points.
376  * The first pose is static while the second pose and the 3D point positions are dynamic so that they will be optimized.<br>
377  * The object points are visible in both frames.
378  * @param pinholeCamera The pinhole camera profile defining the projection
379  * @param firstPose The first (static and precise) pose, must be valid
380  * @param secondPose The second (dynamic and rough) pose, must be valid
381  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points
382  * @param firstImagePoints The accessor for the image points visible in the first frame, one image point for each object point (and with same order)
383  * @param secondImagePoints The accessor for the image points visible in the second frame, one image point for each object point (and with the same order)
384  * @param useDistortionParameters True, to force the usage of the distortion parameters of the given camera object to distort the projected 2D image points before error determination
385  * @param optimizedSecondPose Optional resulting optimized camera pose for the second frame, nullptr otherwise
386  * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
387  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
388  * @param estimator Robust error estimator to be used to measure the pixel errors
389  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
390  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
391  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
392  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
393  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
394  * @param intermediateErrors Optional resulting intermediate (improving) errors
395  * @return True, if succeeded
396  * @see optimizeObjectPointsAndOnePoseIF().
397  */
398  static inline bool optimizeObjectPointsAndOnePose(const PinholeCamera& pinholeCamera, const HomogenousMatrix4& firstPose, const HomogenousMatrix4& secondPose, const ConstIndexedAccessor<Vector3>& objectPoints, const ConstIndexedAccessor<Vector2>& firstImagePoints, const ConstIndexedAccessor<Vector2>& secondImagePoints, const bool useDistortionParameters, HomogenousMatrix4* optimizedSecondPose, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator = Geometry::Estimator::ET_SQUARE, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), const bool onlyFrontObjectPoints = true, Scalar* initialError = nullptr, Scalar* finalError = nullptr, Scalars* intermediateErrors = nullptr);
399 
400  /**
401  * Optimizes the locations of 3D object points visible in two individual (inverted and flipped) camera poses by minimizing the projection error between the 3D object points and the 2D image points.
402  * The first pose is static while the second pose and the 3D point positions are dynamic so that they will be optimized.<br>
403  * The object points are visible in both frames.
404  * @param pinholeCamera The pinhole camera profile defining the projection
405  * @param firstPoseIF The first (static and precise) inverted and flipped pose, must be valid
406  * @param secondPoseIF The second (dynamic and rough) inverted and flipped pose, must be valid
407  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points
408  * @param firstImagePoints The accessor for the image points visible in the first frame, one image point for each object point (and with same order)
409  * @param secondImagePoints The accessor for the image points visible in the second frame, one image point for each object point (and with the same order)
410  * @param useDistortionParameters True, to force the usage of the distortion parameters of the given camera object to distort the projected 2D image points before error determination
411  * @param optimizedSecondPoseIF Optional resulting optimized (inverted and flipped) camera pose for the second frame, nullptr otherwise
412  * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
413  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
414  * @param estimator Robust error estimator to be used to measure the pixel errors
415  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
416  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
417  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
418  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
419  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
420  * @param intermediateErrors Optional resulting intermediate (improving) errors
421  * @return True, if succeeded
422  * @see optimizeObjectPointsAndOnePose().
423  */
424  static bool optimizeObjectPointsAndOnePoseIF(const PinholeCamera& pinholeCamera, const HomogenousMatrix4& firstPoseIF, const HomogenousMatrix4& secondPoseIF, const ConstIndexedAccessor<Vector3>& objectPoints, const ConstIndexedAccessor<Vector2>& firstImagePoints, const ConstIndexedAccessor<Vector2>& secondImagePoints, const bool useDistortionParameters, HomogenousMatrix4* optimizedSecondPoseIF, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator = Geometry::Estimator::ET_SQUARE, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), const bool onlyFrontObjectPoints = true, Scalar* initialError = nullptr, Scalar* finalError = nullptr, Scalars* intermediateErrors = nullptr);
425 
426  /**
427  * Optimizes the locations of 3D object points visible in two individual camera poses by minimizing the projection error between the 3D object points and the 2D image points.
428  * Both camera poses and the 3D point positions are dynamic.<br>
429  * The object points are visible in both frames.
430  * @param pinholeCamera The pinhole camera object defining the projection between 3D object points and 2D image points
431  * @param firstPose The first pose to optimize, must be valid
432  * @param secondPose The second pose to optimize, must be valid
433  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points
434  * @param firstImagePoints The accessor for the image points visible in the first frame, one image point for each object point (and with same order)
435  * @param secondImagePoints The accessor for the image points visible in the second frame, one image point for each object point (and with the same order)
436  * @param useDistortionParameters True, to force the usage of the distortion parameters of the given camera object to distort the projected 2D image points before error determination
437  * @param optimizedFirstPose Optional resulting optimized camera pose for the first frame, nullptr otherwise
438  * @param optimizedSecondPose Optional resulting optimized camera pose for the second frame, nullptr otherwise
439  * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
440  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
441  * @param estimator Robust error estimator to be used to measure the pixel errors
442  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
443  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
444  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
445  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
446  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
447  * @param invertedFirstCovariances Optional set of 2x2 inverted covariance matrices that represent the uncertainties of the first image points (a 2*n x 2 matrix)
448  * @param invertedSecondCovariances Optional set of 2x2 inverted covariance matrices that represent the uncertainties of the second image points (a 2*n x 2 matrix)
449  * @param intermediateErrors Optional resulting intermediate (improving) errors
450  * @return True, if succeeded
451  * @see optimizeObjectPointsAndTwoPosesIF().
452  */
453  static inline bool optimizeObjectPointsAndTwoPoses(const PinholeCamera& pinholeCamera, const HomogenousMatrix4& firstPose, const HomogenousMatrix4& secondPose, const ConstIndexedAccessor<Vector3>& objectPoints, const ConstIndexedAccessor<Vector2>& firstImagePoints, const ConstIndexedAccessor<Vector2>& secondImagePoints, const bool useDistortionParameters, HomogenousMatrix4* optimizedFirstPose, HomogenousMatrix4* optimizedSecondPose, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), const bool onlyFrontObjectPoints = true, Scalar* initialError = nullptr, Scalar* finalError = nullptr, const Matrix* invertedFirstCovariances = nullptr, const Matrix* invertedSecondCovariances = nullptr, Scalars* intermediateErrors = nullptr);
454 
455  /**
456  * Optimizes the locations of 3D object points visible in two individual (inverted and flipped) camera poses by minimizing the projection error between the 3D object points and the 2D image points.
457  * Both camera poses and the 3D point positions are dynamic.<br>
458  * The object points are visible in both frames.
459  * @param pinholeCamera The pinhole camera object defining the projection between 3D object points and 2D image points
460  * @param firstPoseIF The first inverted and pose to optimize, must be valid
461  * @param secondPoseIF The second inverted and pose to optimize, must be valid
462  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points
463  * @param firstImagePoints The accessor for the image points visible in the first frame, one image point for each object point (and with same order)
464  * @param secondImagePoints The accessor for the image points visible in the second frame, one image point for each object point (and with the same order)
465  * @param useDistortionParameters True, to force the usage of the distortion parameters of the given camera object to distort the projected 2D image points before error determination
466  * @param optimizedFirstPoseIF Optional resulting optimized inverted and camera pose for the first frame, nullptr otherwise
467  * @param optimizedSecondPoseIF Optional resulting optimized inverted and camera pose for the second frame, nullptr otherwise
468  * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
469  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
470  * @param estimator Robust error estimator to be used to measure the pixel errors
471  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
472  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
473  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
474  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
475  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
476  * @param invertedFirstCovariances Optional set of 2x2 inverted covariance matrices that represent the uncertainties of the first image points (a 2*n x 2 matrix)
477  * @param invertedSecondCovariances Optional set of 2x2 inverted covariance matrices that represent the uncertainties of the second image points (a 2*n x 2 matrix)
478  * @param intermediateErrors Optional resulting intermediate (improving) errors
479  * @return True, if succeeded
480  * @see optimizeObjectPointsAndTwoPoses().
481  */
482  static bool optimizeObjectPointsAndTwoPosesIF(const PinholeCamera& pinholeCamera, const HomogenousMatrix4& firstPoseIF, const HomogenousMatrix4& secondPoseIF, const ConstIndexedAccessor<Vector3>& objectPoints, const ConstIndexedAccessor<Vector2>& firstImagePoints, const ConstIndexedAccessor<Vector2>& secondImagePoints, const bool useDistortionParameters, HomogenousMatrix4* optimizedFirstPoseIF, HomogenousMatrix4* optimizedSecondPoseIF, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), const bool onlyFrontObjectPoints = true, Scalar* initialError = nullptr, Scalar* finalError = nullptr, const Matrix* invertedFirstCovariances = nullptr, const Matrix* invertedSecondCovariances = nullptr, Scalars* intermediateErrors = nullptr);
483 
484  /**
485  * Optimizes the locations of 3D object points visible in individual camera poses by minimizing the projection error between the 3D object points and the 2D image points.
486  * The number of correspondences may vary between the individual frames (groups).<br>
487  * Each group may address individual object points, however the larger the intersection of sets between the individual 3D object points in the individual frames the better the optimization result.<br>
488  * This function performs a classic Bundle Adjustment using a per-session camera profile (the same identical camera profile for all individual images).
489  * @param camera The camera profile defining the projection for all camera frames, must be valid
490  * @param world_T_cameras The accessor for the known (but rough) poses of the individual camera frames, transforming cameras to world, with default camera pointing towards the negative z-space with y-axis upwards, at least two
491  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points, defined in world
492  * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
493  * @param world_T_optimizedCameras Optional accessor for the resulting optimized camera poses, nullptr otherwise
494  * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
495  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
496  * @param estimator Robust error estimator to be used
497  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
498  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
499  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
500  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
501  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
502  * @param intermediateErrors Optional resulting intermediate (improving) errors
503  * @return True, if succeeded
504  * @see optimizeObjectPointsAndPosesIF(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
505  */
506  static inline bool optimizeObjectPointsAndPoses(const AnyCamera& camera, const ConstIndexedAccessor<HomogenousMatrix4>& world_T_cameras, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, NonconstIndexedAccessor<HomogenousMatrix4>* world_T_optimizedCameras, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator = Geometry::Estimator::ET_SQUARE, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), const bool onlyFrontObjectPoints = true, Scalar* initialError = nullptr, Scalar* finalError = nullptr, Scalars* intermediateErrors = nullptr);
507 
508  /**
509  * Optimizes the locations of 3D object points visible in individual (inverted and flipped) camera poses by minimizing the projection error between the 3D object points and the 2D image points.
510  * The number of correspondences may vary between the individual frames (groups).<br>
511  * Each group may address individual object points, however the larger the intersection of sets between the individual 3D object points in the individual frames the better the optimization result.<br>
512  * This function performs a classic Bundle Adjustment using a per-session camera profile (the same identical camera profile for all individual images).
513  * @param camera The camera profile defining the projection for all camera frames, must be valid
514  * @param flippedCameras_T_world The accessor for the known (but rough) camera frames, with default camera pointing towards the positive z-space with y-axis downwards, at least two
515  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points, defined in world
516  * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
517  * @param flippedOptimizedCameras_T_world Optional accessor for the resulting optimized camera poses, nullptr otherwise
518  * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
519  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)s
520  * @param estimator Robust error estimator to be used
521  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
522  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
523  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
524  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
525  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
526  * @param intermediateErrors Optional resulting intermediate (improving) errors
527  * @return True, if succeeded
528  * @see optimizeObjectPointsAndPoses(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
529  */
530  static inline bool optimizeObjectPointsAndPosesIF(const AnyCamera& camera, const ConstIndexedAccessor<HomogenousMatrix4>& flippedCameras_T_world, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, NonconstIndexedAccessor<HomogenousMatrix4>* flippedOptimizedCameras_T_world, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator = Geometry::Estimator::ET_SQUARE, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), const bool onlyFrontObjectPoints = true, Scalar* initialError = nullptr, Scalar* finalError = nullptr, Scalars* intermediateErrors = nullptr);
531 
532  /**
533  * Optimizes the locations of 3D object points visible in individual camera poses by minimizing the projection error between the 3D object points and the 2D image points.
534  * The number of correspondences may vary between the individual frames (groups).<br>
535  * Each group may address individual object points, however the larger the intersection of sets between the individual 3D object points in the individual frames the better the optimization result.<br>
536  * This function performs a classic Bundle Adjustment using a per-image camera profile (an individual camera profile for each individual image).
537  * @param cameras The camera profiles defining the projection, one for each camera frame, must be valid
538  * @param world_T_cameras The accessor for the known (but rough) poses of the individual camera frames, transforming cameras to world, with default camera pointing towards the negative z-space with y-axis upwards, at least two
539  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points, defined in world
540  * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
541  * @param world_T_optimizedCameras Optional accessor for the resulting optimized camera poses, nullptr otherwise
542  * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
543  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
544  * @param estimator Robust error estimator to be used
545  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
546  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
547  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
548  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
549  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
550  * @param intermediateErrors Optional resulting intermediate (improving) errors
551  * @return True, if succeeded
552  * @see optimizeObjectPointsAndPosesIF(), optimizeObjectPointsAndOrientationalPoses(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
553  */
554  static bool optimizeObjectPointsAndPoses(const ConstIndexedAccessor<const AnyCamera*>& cameras, const ConstIndexedAccessor<HomogenousMatrix4>& world_T_cameras, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, NonconstIndexedAccessor<HomogenousMatrix4>* world_T_optimizedCameras, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator = Geometry::Estimator::ET_SQUARE, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), const bool onlyFrontObjectPoints = true, Scalar* initialError = nullptr, Scalar* finalError = nullptr, Scalars* intermediateErrors = nullptr);
555 
556  /**
557  * Optimizes the locations of 3D object points visible in individual (inverted and flipped) camera poses by minimizing the projection error between the 3D object points and the 2D image points.
558  * The number of correspondences may vary between the individual frames (groups).<br>
559  * Each group may address individual object points, however the larger the intersection of sets between the individual 3D object points in the individual frames the better the optimization result.
560  * This function performs a classic Bundle Adjustment using a per-image camera profile (an individual camera profile for each individual image).
561  * @param cameras The camera profiles defining the projection, one for each camera frame, must be valid
562  * @param flippedCameras_T_world The accessor for the known (but rough) camera frames, with default camera pointing towards the positive z-space with y-axis downwards, at least two
563  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points, defined in world
564  * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
565  * @param flippedOptimizedCameras_T_world Optional accessor for the resulting optimized camera poses, nullptr otherwise
566  * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
567  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)s
568  * @param estimator Robust error estimator to be used
569  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
570  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
571  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
572  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
573  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
574  * @param intermediateErrors Optional resulting intermediate (improving) errors
575  * @return True, if succeeded
576  * @see optimizeObjectPointsAndPoses(), optimizeObjectPointsAndOrientationalPosesIF(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
577  */
578  static bool optimizeObjectPointsAndPosesIF(const ConstIndexedAccessor<const AnyCamera*>& cameras, const ConstIndexedAccessor<HomogenousMatrix4>& flippedCameras_T_world, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, NonconstIndexedAccessor<HomogenousMatrix4>* flippedOptimizedCameras_T_world, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator = Geometry::Estimator::ET_SQUARE, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), const bool onlyFrontObjectPoints = true, Scalar* initialError = nullptr, Scalar* finalError = nullptr, Scalars* intermediateErrors = nullptr);
579 
580  /**
581  * Optimizes the locations of 3D object points visible in individual camera poses by minimizing the projection error between the 3D object points and the 2D image points.
582  * The number of correspondences may vary between the individual frames (groups).<br>
583  * Each group may address individual object points, however the larger the intersection of sets between the individual 3D object points in the individual frames the better the optimization result.<br>
584  * This function performs a Bundle Adjustment but does not modify the translations of camera poses.<br>
585  * The function supports a per-image camera profile (an individual camera profile for each individual image).
586  * @param cameras The camera profiles defining the projection, one for each camera frame, must be valid
587  * @param world_T_cameras The accessor for the known (but rough) poses of the individual camera frames, transforming cameras to world, with default camera pointing towards the negative z-space with y-axis upwards, at least two
588  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points, defined in world
589  * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
590  * @param world_T_optimizedCameras Optional accessor for the resulting optimized camera poses, nullptr otherwise
591  * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
592  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
593  * @param estimator Robust error estimator to be used
594  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
595  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
596  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
597  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
598  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
599  * @param intermediateErrors Optional resulting intermediate (improving) errors
600  * @return True, if succeeded
601  * @see optimizeObjectPointsAndPoses(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
602  */
603  static bool optimizeObjectPointsAndOrientationalPoses(const ConstIndexedAccessor<const AnyCamera*>& cameras, const ConstIndexedAccessor<HomogenousMatrix4>& world_T_cameras, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, NonconstIndexedAccessor<HomogenousMatrix4>* world_T_optimizedCameras, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator = Geometry::Estimator::ET_SQUARE, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), const bool onlyFrontObjectPoints = true, Scalar* initialError = nullptr, Scalar* finalError = nullptr, Scalars* intermediateErrors = nullptr);
604 
605  /**
606  * Optimizes the locations of 3D object points visible in individual (inverted and flipped) camera poses by minimizing the projection error between the 3D object points and the 2D image points.
607  * The number of correspondences may vary between the individual frames (groups).<br>
608  * Each group may address individual object points, however the larger the intersection of sets between the individual 3D object points in the individual frames the better the optimization result.
609  * This function performs a Bundle Adjustment but does not modify the translations of camera poses.<br>
610  * The function supports a per-image camera profile (an individual camera profile for each individual image).
611  * @param cameras The camera profiles defining the projection, one for each camera frame, must be valid
612  * @param flippedCameras_T_world The accessor for the known (but rough) camera frames, with default camera pointing towards the positive z-space with y-axis downwards, at least two
613  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points, defined in world
614  * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
615  * @param flippedOptimizedCameras_T_world Optional accessor for the resulting optimized camera poses, nullptr otherwise
616  * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
617  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)s
618  * @param estimator Robust error estimator to be used
619  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
620  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
621  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
622  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
623  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
624  * @param intermediateErrors Optional resulting intermediate (improving) errors
625  * @return True, if succeeded
626  * @see optimizeObjectPointsAndPosesIF(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
627  */
628  static bool optimizeObjectPointsAndOrientationalPosesIF(const ConstIndexedAccessor<const AnyCamera*>& cameras, const ConstIndexedAccessor<HomogenousMatrix4>& flippedCameras_T_world, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, NonconstIndexedAccessor<HomogenousMatrix4>* flippedOptimizedCameras_T_world, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator = Geometry::Estimator::ET_SQUARE, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), const bool onlyFrontObjectPoints = true, Scalar* initialError = nullptr, Scalar* finalError = nullptr, Scalars* intermediateErrors = nullptr);
629 
630  protected:
631 
632  /**
633  * This function is a slow implementation and has been replaced by a faster implementation.
634  * The code remains for demonstration and evaluation purposes.<br>
635  * Optimizes the locations of 3D object points visible in individual camera poses by minimizing the projection error between the 3D object points and the 2D image points.<br>
636  * The number of correspondences may vary between the individual frames (groups).<br>
637  * Each group may address individual object points, however the larger the intersection of sets between the individual 3D object points in the individual frames the better the optimization result.
638  * @param camera The camera profile defining the projection, must be valid
639  * @param world_T_cameras The accessor for the known (but rough) poses of the individual camera frames, transforming cameras to world, with default camera pointing towards the negative z-space with y-axis upwards, at least two
640  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points, defined in world
641  * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
642  * @param world_T_optimizedCameras Optional accessor for the resulting optimized camera poses, nullptr otherwise
643  * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
644  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
645  * @param estimator Robust error estimator to be used
646  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
647  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
648  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
649  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
650  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
651  * @param intermediateErrors Optional resulting intermediate (improving) errors
652  * @return True, if succeeded
653  * @see optimizeObjectPointsAndPoses, optimizeObjectPointsAndPosesIF(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
654  */
655  static bool slowOptimizeObjectPointsAndPoses(const AnyCamera& camera, const ConstIndexedAccessor<HomogenousMatrix4>& world_T_cameras, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, NonconstIndexedAccessor<HomogenousMatrix4>* world_T_optimizedCameras, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator = Geometry::Estimator::ET_SQUARE, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), const bool onlyFrontObjectPoints = true, Scalar* initialError = nullptr, Scalar* finalError = nullptr, Scalars* intermediateErrors = nullptr);
656 
657  /**
658  * This function is a slow implementation and has been replaced by a faster implementation.
659  * The code remains for demonstration and evaluation purposes.<br>
660  * Optimizes the locations of 3D object points visible in individual (inverted and flipped) camera poses by minimizing the projection error between the 3D object points and the 2D image points.<br>
661  * The number of correspondences may vary between the individual frames (groups).<br>
662  * Each group may address individual object points, however the larger the intersection of sets between the individual 3D object points in the individual frames the better the optimization result.
663  * @param camera The camera profile defining the projection, must be valid
664  * @param flippedCameras_T_world The accessor for the known (but rough) camera frames, with default camera pointing towards the positive z-space with y-axis downwards, at least two
665  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points, defined in world
666  * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
667  * @param flippedOptimizedCameras_T_world Optional accessor for the resulting optimized camera poses, nullptr otherwise
668  * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
669  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
670  * @param estimator Robust error estimator to be used
671  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
672  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
673  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
674  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
675  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
676  * @param intermediateErrors Optional resulting intermediate (improving) errors
677  * @return True, if succeeded
678  * @see optimizeObjectPointsAndPosesIF, slowOptimizeObjectPointsAndPoses(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
679  */
680  static bool slowOptimizeObjectPointsAndPosesIF(const AnyCamera& camera, const ConstIndexedAccessor<HomogenousMatrix4>& flippedCameras_T_world, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, NonconstIndexedAccessor<HomogenousMatrix4>* flippedOptimizedCameras_T_world, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator = Geometry::Estimator::ET_SQUARE, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), const bool onlyFrontObjectPoints = true, Scalar* initialError = nullptr, Scalar* finalError = nullptr, Scalars* intermediateErrors = nullptr);
681 
682  /**
683  * Deprecated.
684  *
685  * This function is a slow implementation and has been replaced by a faster implementation.
686  * The code remains for demonstration and evaluation purposes.<br>
687  * Optimizes the locations of 3D object points visible in individual camera poses by minimizing the projection error between the 3D object points and the 2D image points.<br>
688  * The number of correspondences may vary between the individual frames (groups).<br>
689  * Each group may address individual object points, however the larger the intersection of sets between the individual 3D object points in the individual frames the better the optimization result.<br>
690  * @param pinholeCamera The pinhole camera profile defining the projection
691  * @param poses The accessor for the known (but rough) poses of the individual camera frames
692  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points
693  * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
694  * @param useDistortionParameters True, to force the usage of the distortion parameters of the given camera object to distort the projected 2D image points before error determination
695  * @param optimizedPoses Optional accessor for the resulting optimized camera poses, nullptr otherwise
696  * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
697  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
698  * @param estimator Robust error estimator to be used
699  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
700  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
701  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
702  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
703  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
704  * @param intermediateErrors Optional resulting intermediate (improving) errors
705  * @return True, if succeeded
706  * @see optimizeObjectPointsAndPoses, optimizeObjectPointsAndPosesIF(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
707  */
708  static inline bool slowOptimizeObjectPointsAndPoses(const PinholeCamera& pinholeCamera, const ConstIndexedAccessor<HomogenousMatrix4>& poses, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, const bool useDistortionParameters, NonconstIndexedAccessor<HomogenousMatrix4>* optimizedPoses, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator = Geometry::Estimator::ET_SQUARE, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), const bool onlyFrontObjectPoints = true, Scalar* initialError = nullptr, Scalar* finalError = nullptr, Scalars* intermediateErrors = nullptr);
709 
710  /**
711  * Deprecated.
712  *
713  * This function is a slow implementation and has been replaced by a faster implementation.
714  * The code remains for demonstration and evaluation purposes.<br>
715  * Optimizes the locations of 3D object points visible in individual (inverted and flipped) camera poses by minimizing the projection error between the 3D object points and the 2D image points.<br>
716  * The number of correspondences may vary between the individual frames (groups).<br>
717  * Each group may address individual object points, however the larger the intersection of sets between the individual 3D object points in the individual frames the better the optimization result.<br>
718  * @param pinholeCamera The pinhole camera profile defining the projection
719  * @param posesIF The accessor for the known (but rough) inverted and flipped poses of the individual camera frames
720  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points
721  * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
722  * @param useDistortionParameters True, to force the usage of the distortion parameters of the given camera object to distort the projected 2D image points before error determination
723  * @param optimizedPosesIF Optional accessor for the resulting optimized camera poses, nullptr otherwise
724  * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
725  * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
726  * @param estimator Robust error estimator to be used
727  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
728  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
729  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
730  * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
731  * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
732  * @param intermediateErrors Optional resulting intermediate (improving) errors
733  * @return True, if succeeded
734  * @see optimizeObjectPointsAndPosesIF, slowOptimizeObjectPointsAndPoses(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
735  */
736  static inline bool slowOptimizeObjectPointsAndPosesIF(const PinholeCamera& pinholeCamera, const ConstIndexedAccessor<HomogenousMatrix4>& posesIF, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, const bool useDistortionParameters, NonconstIndexedAccessor<HomogenousMatrix4>* optimizedPosesIF, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator = Geometry::Estimator::ET_SQUARE, const Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), const bool onlyFrontObjectPoints = true, Scalar* initialError = nullptr, Scalar* finalError = nullptr, Scalars* intermediateErrors = nullptr);
737 
738  /**
739  * Minimizes the projection errors of a subset of given 3D object points, visible in several individual (fixed) camera frames, by minimizing the projection error between the 3D object point and the 2D image points.
740  * Beware: The given inverted and flipped 6DOF poses are not equivalent to a standard extrinsic camera matrix.<br>
741  * @param pinholeCamera The pinhole camera object defining the projection between 3D object points and 2D image points
742  * @param invertedFlippedPoses The accessor for the known (and fixed) poses of the individual camera frames
743  * @param objectPoints The accessor for the known (but rough) locations of the 3D object points
744  * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
745  * @param distortImagePoints True, to force the usage of the distortion parameters of the given camera object to distort the projected 2D image points before error determination
746  * @param optimizedObjectPoints Resulting optimized 3D object points, the caller must provide enough memory to store the optimized 3D points
747  * @param iterations Number of iterations to be applied at most, if no convergence can be reached
748  * @param estimator Robust error estimator to be used
749  * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
750  * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
751  * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
752  * @param firstObjectPoint The first object point to be handled
753  * @param numberObjectPoints The number of object points to be handled
754  * @see optimizeObjectPointsForFixedPosesIF().
755  */
756  static void optimizeObjectPointsForFixedPosesIFSubset(const PinholeCamera* pinholeCamera, const ConstIndexedAccessor<HomogenousMatrix4>* invertedFlippedPoses, const ConstIndexedAccessor<Vector3>* objectPoints, const ObjectPointGroupsAccessor* correspondenceGroups, const bool distortImagePoints, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Estimator::EstimatorType estimator, Scalar lambda, const Scalar lambdaFactor, const bool onlyFrontObjectPoints, const unsigned int firstObjectPoint, const unsigned int numberObjectPoints);
757 };
758 
759 inline bool NonLinearOptimizationObjectPoint::optimizeObjectPointForFixedPoses(const AnyCamera& anyCamera, const ConstIndexedAccessor<HomogenousMatrix4>& world_T_cameras, const Vector3& worldObjectPoint, const ConstIndexedAccessor<Vector2>& imagePoints, Vector3& optimizedWorldObjectPoint, const unsigned int iterations, const Estimator::EstimatorType estimator, Scalar lambda, const Scalar lambdaFactor, const bool onlyFrontObjectPoints, Scalar* initialRobustError, Scalar* finalRobustError, Scalars* intermediateRobustErrors)
760 {
761  const HomogenousMatrices4 flippedCameras_T_world(PinholeCamera::standard2InvertedFlipped(Accessor::accessor2elements(world_T_cameras)));
762 
763  return optimizeObjectPointForFixedPosesIF(anyCamera, ConstArrayAccessor<HomogenousMatrix4>(flippedCameras_T_world), worldObjectPoint, imagePoints, optimizedWorldObjectPoint, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialRobustError, finalRobustError, intermediateRobustErrors);
764 }
765 
766 inline bool NonLinearOptimizationObjectPoint::optimizeObjectPointForFixedPoses(const ConstIndexedAccessor<const AnyCamera*>& cameras, const ConstIndexedAccessor<HomogenousMatrix4>& world_T_cameras, const Vector3& worldObjectPoint, const ConstIndexedAccessor<Vector2>& imagePoints, Vector3& optimizedWorldObjectPoint, const unsigned int iterations, const Estimator::EstimatorType estimator, Scalar lambda, const Scalar lambdaFactor, const bool onlyFrontObjectPoints, Scalar* initialRobustError, Scalar* finalRobustError, Scalars* intermediateRobustErrors)
767 {
768  const HomogenousMatrices4 flippedCameras_T_world(AnyCamera::standard2InvertedFlipped(Accessor::accessor2elements(world_T_cameras)));
769 
770  return optimizeObjectPointForFixedPosesIF(cameras, ConstArrayAccessor<HomogenousMatrix4>(flippedCameras_T_world), worldObjectPoint, imagePoints, optimizedWorldObjectPoint, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialRobustError, finalRobustError, intermediateRobustErrors);
771 }
772 
773 inline bool NonLinearOptimizationObjectPoint::optimizeObjectPointForFixedStereoPoses(const AnyCamera& anyCameraA, const AnyCamera& anyCameraB, const ConstIndexedAccessor<HomogenousMatrix4>& world_T_camerasA, const ConstIndexedAccessor<HomogenousMatrix4>& world_T_camerasB, const Vector3& worldObjectPoint, const ConstIndexedAccessor<Vector2>& imagePointAccessorA, const ConstIndexedAccessor<Vector2>& imagePointAccessorB, Vector3& optimizedWorldObjectPoint, const unsigned int iterations, const Estimator::EstimatorType estimator, Scalar lambda, const Scalar lambdaFactor, const bool onlyFrontObjectPoints, Scalar* initialRobustError, Scalar* finalRobustError, Scalars* intermediateRobustErrors)
774 {
775  const HomogenousMatrices4 flippedCamerasA_T_world(PinholeCamera::standard2InvertedFlipped(Accessor::accessor2elements(world_T_camerasA)));
776  const HomogenousMatrices4 flippedCamerasB_T_world(PinholeCamera::standard2InvertedFlipped(Accessor::accessor2elements(world_T_camerasB)));
777 
778  return optimizeObjectPointForFixedStereoPosesIF(anyCameraA, anyCameraB, ConstArrayAccessor<HomogenousMatrix4>(flippedCamerasA_T_world), ConstArrayAccessor<HomogenousMatrix4>(flippedCamerasB_T_world), worldObjectPoint, imagePointAccessorA, imagePointAccessorB, optimizedWorldObjectPoint, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialRobustError, finalRobustError, intermediateRobustErrors);
779 }
780 
781 inline bool NonLinearOptimizationObjectPoint::optimizeObjectPointsForFixedPoses(const PinholeCamera& pinholeCamera, const ConstIndexedAccessor<HomogenousMatrix4>& poseAccessor, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, const bool distortImagePoints, NonconstIndexedAccessor<Vector3>& optimizedObjectPoints, const unsigned int iterations, const Estimator::EstimatorType estimator, Scalar lambda, const Scalar lambdaFactor, const bool onlyFrontObjectPoints, Worker* worker)
782 {
783  ocean_assert(!poseAccessor.isEmpty() && !objectPoints.isEmpty());
784  ocean_assert(objectPoints.size() == correspondenceGroups.groups());
785 
786  ocean_assert(lambda >= 0);
787  ocean_assert(lambdaFactor >= 1);
788 
789  HomogenousMatrices4 invertedFlippedPoses;
790  invertedFlippedPoses.reserve(poseAccessor.size());
791 
792  for (size_t n = 0; n < poseAccessor.size(); ++n)
793  {
794  invertedFlippedPoses.push_back(PinholeCamera::standard2InvertedFlipped(poseAccessor[n]));
795  }
796 
797  return optimizeObjectPointsForFixedPosesIF(pinholeCamera, ConstArrayAccessor<HomogenousMatrix4>(invertedFlippedPoses), objectPoints, correspondenceGroups, distortImagePoints, optimizedObjectPoints, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, worker);
798 }
799 
800 inline bool NonLinearOptimizationObjectPoint::optimizeObjectPointForFixedOrientations(const AnyCamera& camera, const ConstIndexedAccessor<SquareMatrix3>& world_R_cameras, const ConstIndexedAccessor<Vector2>& imagePoints, const Vector3& objectPoint, const Scalar objectPointDistance, Vector3& optimizedObjectPoint, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator, const Scalar lambda, const Scalar lambdaFactor, const bool onlyFrontObjectPoint, Scalar* initialError, Scalar* finalError, Scalars* intermediateErrors)
801 {
802  SquareMatrices3 flippedCameras_R_world;
803  flippedCameras_R_world.reserve(world_R_cameras.size());
804 
805  for (size_t n = 0; n < world_R_cameras.size(); ++n)
806  {
807  flippedCameras_R_world.emplace_back(AnyCamera::standard2InvertedFlipped(world_R_cameras[n]));
808  }
809 
810  return optimizeObjectPointForFixedOrientationsIF(camera, ConstArrayAccessor<SquareMatrix3>(flippedCameras_R_world), imagePoints, objectPoint, objectPointDistance, optimizedObjectPoint, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoint, initialError, finalError, intermediateErrors);
811 }
812 
813 inline bool NonLinearOptimizationObjectPoint::optimizeObjectPointsAndOnePose(const PinholeCamera& pinholeCamera, const HomogenousMatrix4& firstPose, const HomogenousMatrix4& secondPose, const ConstIndexedAccessor<Vector3>& objectPoints, const ConstIndexedAccessor<Vector2>& firstImagePoints, const ConstIndexedAccessor<Vector2>& secondImagePoints, const bool useDistortionParameters, HomogenousMatrix4* optimizedSecondPose, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator, const Scalar lambda, const Scalar lambdaFactor, const bool onlyFrontObjectPoints, Scalar* initialError, Scalar* finalError, Scalars* intermediateErrors)
814 {
815  const HomogenousMatrix4 firstPoseIF(PinholeCamera::standard2InvertedFlipped(firstPose));
816  const HomogenousMatrix4 secondPoseIF(PinholeCamera::standard2InvertedFlipped(secondPose));
817 
818  if (!optimizeObjectPointsAndOnePoseIF(pinholeCamera, firstPoseIF, secondPoseIF, objectPoints, firstImagePoints, secondImagePoints, useDistortionParameters, optimizedSecondPose, optimizedObjectPoints, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialError, finalError, intermediateErrors))
819  {
820  return false;
821  }
822 
823  if (optimizedSecondPose)
824  {
825  *optimizedSecondPose = PinholeCamera::invertedFlipped2Standard(*optimizedSecondPose);
826  }
827 
828  return true;
829 }
830 
831 inline bool NonLinearOptimizationObjectPoint::optimizeObjectPointsAndTwoPoses(const PinholeCamera& pinholeCamera, const HomogenousMatrix4& firstPose, const HomogenousMatrix4& secondPose, const ConstIndexedAccessor<Vector3>& objectPoints, const ConstIndexedAccessor<Vector2>& firstImagePoints, const ConstIndexedAccessor<Vector2>& secondImagePoints, const bool useDistortionParameters, HomogenousMatrix4* optimizedFirstPose, HomogenousMatrix4* optimizedSecondPose, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator, const Scalar lambda, const Scalar lambdaFactor, const bool onlyFrontObjectPoints, Scalar* initialError, Scalar* finalError, const Matrix* invertedFirstCovariances, const Matrix* invertedSecondCovariances, Scalars* intermediateErrors)
832 {
833  const HomogenousMatrix4 firstPoseIF(PinholeCamera::standard2InvertedFlipped(firstPose));
834  const HomogenousMatrix4 secondPoseIF(PinholeCamera::standard2InvertedFlipped(secondPose));
835 
836  if (!optimizeObjectPointsAndTwoPosesIF(pinholeCamera, firstPoseIF, secondPoseIF, objectPoints, firstImagePoints, secondImagePoints, useDistortionParameters, optimizedFirstPose, optimizedSecondPose, optimizedObjectPoints, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialError, finalError, invertedFirstCovariances, invertedSecondCovariances, intermediateErrors))
837  {
838  return false;
839  }
840 
841  if (optimizedFirstPose)
842  {
843  *optimizedFirstPose = PinholeCamera::invertedFlipped2Standard(*optimizedFirstPose);
844  }
845 
846  if (optimizedSecondPose)
847  {
848  *optimizedSecondPose = PinholeCamera::invertedFlipped2Standard(*optimizedSecondPose);
849  }
850 
851  return true;
852 }
853 
854 inline bool NonLinearOptimizationObjectPoint::optimizeObjectPointsAndPoses(const AnyCamera& camera, const ConstIndexedAccessor<HomogenousMatrix4>& world_T_cameras, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, NonconstIndexedAccessor<HomogenousMatrix4>* world_T_optimizedCameras, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator, const Scalar lambda, const Scalar lambdaFactor, const bool onlyFrontObjectPoints, Scalar* initialError, Scalar* finalError, Scalars* intermediateErrors)
855 {
856 #if 1
857  // creating local pointer to avoid Clang compiler bug
858  const AnyCamera* cameraPointer = &camera;
859  const ConstElementAccessor<const AnyCamera*> cameraAccessor(world_T_cameras.size(), cameraPointer);
860 #else
861  const ConstElementAccessor<const AnyCamera*> cameraAccessor(world_T_cameras.size(), &camera);
862 #endif
863 
864  const HomogenousMatrices4 flippedCameras_T_world(AnyCamera::standard2InvertedFlipped(Accessor::accessor2elements(world_T_cameras)));
865 
866  HomogenousMatrices4 flippedOptimizedCameras_T_world;
867  NonconstArrayAccessor<HomogenousMatrix4> accessor_flippedOptimizedCameras_T_world(flippedOptimizedCameras_T_world, world_T_optimizedCameras ? world_T_cameras.size() : 0);
868 
869  if (!optimizeObjectPointsAndPosesIF(cameraAccessor, ConstArrayAccessor<HomogenousMatrix4>(flippedCameras_T_world), objectPoints, correspondenceGroups, accessor_flippedOptimizedCameras_T_world.pointer(), optimizedObjectPoints, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialError, finalError, intermediateErrors))
870  {
871  return false;
872  }
873 
874  if (world_T_optimizedCameras != nullptr)
875  {
876  for (size_t n = 0; n < flippedOptimizedCameras_T_world.size(); ++n)
877  {
878  (*world_T_optimizedCameras)[n] = AnyCamera::invertedFlipped2Standard(flippedOptimizedCameras_T_world[n]);
879  }
880  }
881 
882  return true;
883 }
884 
885 inline bool NonLinearOptimizationObjectPoint::optimizeObjectPointsAndPosesIF(const AnyCamera& camera, const ConstIndexedAccessor<HomogenousMatrix4>& flippedCameras_T_world, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, NonconstIndexedAccessor<HomogenousMatrix4>* flippedOptimizedCameras_T_world, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator, const Scalar lambda, const Scalar lambdaFactor, const bool onlyFrontObjectPoints, Scalar* initialError, Scalar* finalError, Scalars* intermediateErrors)
886 {
887 #if 1
888  // creating local pointer to avoid Clang compiler bug
889  const AnyCamera* cameraPointer = &camera;
890  const ConstElementAccessor<const AnyCamera*> cameraAccessor(flippedCameras_T_world.size(), cameraPointer);
891 #else
892  const ConstElementAccessor<const AnyCamera*> cameraAccessor(flippedCameras_T_world.size(), &camera);
893 #endif
894 
895  return optimizeObjectPointsAndPosesIF(cameraAccessor, flippedCameras_T_world, objectPoints, correspondenceGroups, flippedOptimizedCameras_T_world, optimizedObjectPoints, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialError, finalError, intermediateErrors);
896 }
897 
898 inline bool NonLinearOptimizationObjectPoint::slowOptimizeObjectPointsAndPoses(const PinholeCamera& camera, const ConstIndexedAccessor<HomogenousMatrix4>& poses, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, const bool useDistortionParameters, NonconstIndexedAccessor<HomogenousMatrix4>* optimizedPoses, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator, const Scalar lambda, const Scalar lambdaFactor, const bool onlyFrontObjectPoints, Scalar* initialError, Scalar* finalError, Scalars* intermediateErrors)
899 {
900  const AnyCameraPinhole anyCameraPinhole(PinholeCamera(camera, useDistortionParameters));
901 
902  return slowOptimizeObjectPointsAndPoses(anyCameraPinhole, poses, objectPoints, correspondenceGroups, optimizedPoses, optimizedObjectPoints, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialError, finalError, intermediateErrors);
903 }
904 
905 inline bool NonLinearOptimizationObjectPoint::slowOptimizeObjectPointsAndPosesIF(const PinholeCamera& camera, const ConstIndexedAccessor<HomogenousMatrix4>& posesIF, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, const bool useDistortionParameters, NonconstIndexedAccessor<HomogenousMatrix4>* optimizedPosesIF, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator, const Scalar lambda, const Scalar lambdaFactor, const bool onlyFrontObjectPoints, Scalar* initialError, Scalar* finalError, Scalars* intermediateErrors)
906 {
907  const AnyCameraPinhole anyCameraPinhole(PinholeCamera(camera, useDistortionParameters));
908 
909  return slowOptimizeObjectPointsAndPosesIF(anyCameraPinhole, posesIF, objectPoints, correspondenceGroups, optimizedPosesIF, optimizedObjectPoints, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialError, finalError, intermediateErrors);
910 }
911 
912 
913 }
914 
915 }
916 
917 #endif // META_OCEAN_GEOMETRY_NON_LINEAR_OPTIMIZATION_OBJECT_POINT_H
virtual size_t size() const =0
Returns the number of accessible elements of this accessor object.
bool isEmpty() const
Returns whether this accessor provides no elements.
Definition: Accessor.h:1578
static std::vector< typename TAccessor::Type > accessor2elements(const TAccessor &accessor)
Returns all elements of a given accessor (as a block).
Definition: Accessor.h:1584
This class implements the abstract base class for all AnyCamera objects.
Definition: AnyCamera.h:130
This class implements a specialized AnyCamera object wrapping the actual camera model.
Definition: AnyCamera.h:494
static HomogenousMatrixT4< U > standard2InvertedFlipped(const HomogenousMatrixT4< U > &world_T_camera)
Transforms a standard homogenous 4x4 viewing (extrinsic camera) matrix into an inverted and flipped c...
Definition: Camera.h:734
static HomogenousMatrixT4< U > invertedFlipped2Standard(const HomogenousMatrixT4< U > &flippedCamera_T_world)
Transforms an inverted and flipped camera pose into a standard camera pose.
Definition: Camera.h:757
This class implements an accessor providing direct access to a constant array of elements.
Definition: Accessor.h:400
This class implements an accessor providing direct access to a constant array of elements while all e...
Definition: Accessor.h:942
EstimatorType
Definition of individual robust estimator types.
Definition: Estimator.h:34
@ ET_SQUARE
The standard square error estimator (L2).
Definition: Estimator.h:52
size_t groups() const
Returns the number of groups of this accessor.
Definition: NonLinearOptimization.h:668
This class implements an abstract specialization of the accessor for groups of pairs for object point...
Definition: NonLinearOptimization.h:159
This class implements the basic functions for least square or robust optimization algorithms for non ...
Definition: NonLinearOptimization.h:34
Forward declaration of a highly optimized provider object allowing to optimize one camera pose and se...
Definition: NonLinearOptimizationObjectPoint.h:100
Forward declaration of a highly optimized provider object allowing to optimize the orientations of se...
Definition: NonLinearOptimizationObjectPoint.h:121
Forward declaration of a highly optimized provider object allowing to optimize several camera pose an...
Definition: NonLinearOptimizationObjectPoint.h:113
This class implements least square or robust optimization algorithms optimizing the locations of 3D o...
Definition: NonLinearOptimizationObjectPoint.h:32
std::vector< StaticMatrix6x6 > StaticMatrices6x6
Definition of a vector holding 6x6 matrices.
Definition: NonLinearOptimizationObjectPoint.h:68
std::vector< StaticMatrix3x3 > StaticMatrices3x3
Definition of a vector holding 3x3 matrices.
Definition: NonLinearOptimizationObjectPoint.h:58
static bool optimizeObjectPointsForFixedPoses(const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< HomogenousMatrix4 > &poseAccessor, const ConstIndexedAccessor< Vector3 > &objectPoints, const ObjectPointGroupsAccessor &correspondenceGroups, const bool distortImagePoints, NonconstIndexedAccessor< Vector3 > &optimizedObjectPoints, const unsigned int iterations=5u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=10, const bool onlyFrontObjectPoints=true, Worker *worker=nullptr)
Minimizes the projection errors of given 3D object points, visible in several individual (fixed) came...
Definition: NonLinearOptimizationObjectPoint.h:781
static bool optimizeObjectPointsAndOrientationalPosesIF(const ConstIndexedAccessor< const AnyCamera * > &cameras, const ConstIndexedAccessor< HomogenousMatrix4 > &flippedCameras_T_world, const ConstIndexedAccessor< Vector3 > &objectPoints, const ObjectPointGroupsAccessor &correspondenceGroups, NonconstIndexedAccessor< HomogenousMatrix4 > *flippedOptimizedCameras_T_world, NonconstIndexedAccessor< Vector3 > *optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), const bool onlyFrontObjectPoints=true, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
Optimizes the locations of 3D object points visible in individual (inverted and flipped) camera poses...
static bool optimizeObjectPointForFixedOrientationsIF(const AnyCamera &camera, const ConstIndexedAccessor< SquareMatrix3 > &flippedCameras_R_world, const ConstIndexedAccessor< Vector2 > &imagePoints, const Vector3 &objectPoint, const Scalar objectPointDistance, Vector3 &optimizedObjectPoint, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), const bool onlyFrontObjectPoint=true, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
Optimizes the locations of one 3D object point visible in individual (fixed) camera poses all located...
static bool slowOptimizeObjectPointsAndPosesIF(const AnyCamera &camera, const ConstIndexedAccessor< HomogenousMatrix4 > &flippedCameras_T_world, const ConstIndexedAccessor< Vector3 > &objectPoints, const ObjectPointGroupsAccessor &correspondenceGroups, NonconstIndexedAccessor< HomogenousMatrix4 > *flippedOptimizedCameras_T_world, NonconstIndexedAccessor< Vector3 > *optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), const bool onlyFrontObjectPoints=true, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
This function is a slow implementation and has been replaced by a faster implementation.
StaticMatrix< Scalar, 3, 6 > StaticMatrix3x6
Definition of a 3x6 matrix.
Definition: NonLinearOptimizationObjectPoint.h:43
StaticMatrix< Scalar, 3, 3 > StaticMatrix3x3
Definition of a 3x3 matrix.
Definition: NonLinearOptimizationObjectPoint.h:38
static bool optimizeObjectPointsAndTwoPoses(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &firstPose, const HomogenousMatrix4 &secondPose, const ConstIndexedAccessor< Vector3 > &objectPoints, const ConstIndexedAccessor< Vector2 > &firstImagePoints, const ConstIndexedAccessor< Vector2 > &secondImagePoints, const bool useDistortionParameters, HomogenousMatrix4 *optimizedFirstPose, HomogenousMatrix4 *optimizedSecondPose, NonconstIndexedAccessor< Vector3 > *optimizedObjectPoints, const unsigned int iterations, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), const bool onlyFrontObjectPoints=true, Scalar *initialError=nullptr, Scalar *finalError=nullptr, const Matrix *invertedFirstCovariances=nullptr, const Matrix *invertedSecondCovariances=nullptr, Scalars *intermediateErrors=nullptr)
Optimizes the locations of 3D object points visible in two individual camera poses by minimizing the ...
Definition: NonLinearOptimizationObjectPoint.h:831
StaticMatrix< Scalar, 6, 3 > StaticMatrix6x3
Definition of a 6x3 matrix.
Definition: NonLinearOptimizationObjectPoint.h:48
static bool optimizeObjectPointForFixedStereoPoses(const AnyCamera &anyCameraA, const AnyCamera &anyCameraB, const ConstIndexedAccessor< HomogenousMatrix4 > &world_T_camerasA, const ConstIndexedAccessor< HomogenousMatrix4 > &world_T_camerasB, const Vector3 &worldObjectPoint, const ConstIndexedAccessor< Vector2 > &imagePointAccessorA, const ConstIndexedAccessor< Vector2 > &imagePointAccessorB, Vector3 &optimizedWorldObjectPoint, const unsigned int iterations=5u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=10, const bool onlyFrontObjectPoints=true, Scalar *initialRobustError=nullptr, Scalar *finalRobustError=nullptr, Scalars *intermediateRobustErrors=nullptr)
Minimizes the projection errors for one given 3D object point, visible in several individual (fixed) ...
Definition: NonLinearOptimizationObjectPoint.h:773
static bool optimizeObjectPointsAndOnePose(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &firstPose, const HomogenousMatrix4 &secondPose, const ConstIndexedAccessor< Vector3 > &objectPoints, const ConstIndexedAccessor< Vector2 > &firstImagePoints, const ConstIndexedAccessor< Vector2 > &secondImagePoints, const bool useDistortionParameters, HomogenousMatrix4 *optimizedSecondPose, NonconstIndexedAccessor< Vector3 > *optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), const bool onlyFrontObjectPoints=true, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
Optimizes the locations of 3D object points visible in two individual camera poses by minimizing the ...
Definition: NonLinearOptimizationObjectPoint.h:813
static bool optimizeObjectPointForFixedStereoPosesIF(const AnyCamera &anyCameraA, const AnyCamera &anyCameraB, const ConstIndexedAccessor< HomogenousMatrix4 > &flippedCamerasA_T_world, const ConstIndexedAccessor< HomogenousMatrix4 > &flippedCamerasB_T_world, const Vector3 &worldObjectPoint, const ConstIndexedAccessor< Vector2 > &imagePointAccessorA, const ConstIndexedAccessor< Vector2 > &imagePointAccessorB, Vector3 &optimizedWorldObjectPoint, const unsigned int iterations=5u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=10, const bool onlyFrontObjectPoints=true, Scalar *initialRobustError=nullptr, Scalar *finalRobustError=nullptr, Scalars *intermediateRobustErrors=nullptr)
Minimizes the projection errors for one given 3D object point, visible in several individual (fixed) ...
static bool optimizeObjectPointsForFixedPosesIF(const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< HomogenousMatrix4 > &invertedFlippedPoses, const ConstIndexedAccessor< Vector3 > &objectPoints, const ObjectPointGroupsAccessor &correspondenceGroups, const bool distortImagePoints, NonconstIndexedAccessor< Vector3 > &optimizedObjectPoints, const unsigned int iterations=5u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=10, const bool onlyFrontObjectPoints=true, Worker *worker=nullptr)
Minimizes the projection errors of given 3D object points, visible in several individual (fixed) came...
static bool optimizeObjectPointsAndOrientations(const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< SquareMatrix3 > &orientations, const ConstIndexedAccessor< Vector3 > &objectPoints, const ObjectPointGroupsAccessor &correspondenceGroups, const Scalar objectPointDistance, NonconstIndexedAccessor< SquareMatrix3 > *optimizedOrientations, NonconstIndexedAccessor< Vector3 > *optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), const bool onlyFrontObjectPoints=true, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
Optimizes the locations of 3D object points visible in individual camera poses all located at the ori...
static bool optimizeObjectPointsAndPosesIF(const ConstIndexedAccessor< const AnyCamera * > &cameras, const ConstIndexedAccessor< HomogenousMatrix4 > &flippedCameras_T_world, const ConstIndexedAccessor< Vector3 > &objectPoints, const ObjectPointGroupsAccessor &correspondenceGroups, NonconstIndexedAccessor< HomogenousMatrix4 > *flippedOptimizedCameras_T_world, NonconstIndexedAccessor< Vector3 > *optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), const bool onlyFrontObjectPoints=true, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
Optimizes the locations of 3D object points visible in individual (inverted and flipped) camera poses...
static bool optimizeObjectPointsAndPosesIF(const AnyCamera &camera, const ConstIndexedAccessor< HomogenousMatrix4 > &flippedCameras_T_world, const ConstIndexedAccessor< Vector3 > &objectPoints, const ObjectPointGroupsAccessor &correspondenceGroups, NonconstIndexedAccessor< HomogenousMatrix4 > *flippedOptimizedCameras_T_world, NonconstIndexedAccessor< Vector3 > *optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), const bool onlyFrontObjectPoints=true, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
Optimizes the locations of 3D object points visible in individual (inverted and flipped) camera poses...
Definition: NonLinearOptimizationObjectPoint.h:885
static bool optimizeObjectPointsAndTwoPosesIF(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &firstPoseIF, const HomogenousMatrix4 &secondPoseIF, const ConstIndexedAccessor< Vector3 > &objectPoints, const ConstIndexedAccessor< Vector2 > &firstImagePoints, const ConstIndexedAccessor< Vector2 > &secondImagePoints, const bool useDistortionParameters, HomogenousMatrix4 *optimizedFirstPoseIF, HomogenousMatrix4 *optimizedSecondPoseIF, NonconstIndexedAccessor< Vector3 > *optimizedObjectPoints, const unsigned int iterations, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), const bool onlyFrontObjectPoints=true, Scalar *initialError=nullptr, Scalar *finalError=nullptr, const Matrix *invertedFirstCovariances=nullptr, const Matrix *invertedSecondCovariances=nullptr, Scalars *intermediateErrors=nullptr)
Optimizes the locations of 3D object points visible in two individual (inverted and flipped) camera p...
static bool optimizeObjectPointsAndPoses(const AnyCamera &camera, const ConstIndexedAccessor< HomogenousMatrix4 > &world_T_cameras, const ConstIndexedAccessor< Vector3 > &objectPoints, const ObjectPointGroupsAccessor &correspondenceGroups, NonconstIndexedAccessor< HomogenousMatrix4 > *world_T_optimizedCameras, NonconstIndexedAccessor< Vector3 > *optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), const bool onlyFrontObjectPoints=true, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
Optimizes the locations of 3D object points visible in individual camera poses by minimizing the proj...
Definition: NonLinearOptimizationObjectPoint.h:854
std::vector< StaticMatrix6x3 > StaticMatrices6x3
Definition of a vector holding 6x3 matrices.
Definition: NonLinearOptimizationObjectPoint.h:63
static bool optimizeObjectPointForFixedPosesIF(const AnyCamera &camera, const ConstIndexedAccessor< HomogenousMatrix4 > &flippedCameras_T_world, const Vector3 &worldObjectPoint, const ConstIndexedAccessor< Vector2 > &imagePoints, Vector3 &optimizedWorldObjectPoint, const unsigned int iterations=5u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=10, const bool onlyFrontObjectPoints=true, Scalar *initialRobustError=nullptr, Scalar *finalRobustError=nullptr, Scalars *intermediateRobustErrors=nullptr)
Minimizes the projection errors for one given 3D object point, visible in several individual (fixed) ...
static bool slowOptimizeObjectPointsAndPoses(const AnyCamera &camera, const ConstIndexedAccessor< HomogenousMatrix4 > &world_T_cameras, const ConstIndexedAccessor< Vector3 > &objectPoints, const ObjectPointGroupsAccessor &correspondenceGroups, NonconstIndexedAccessor< HomogenousMatrix4 > *world_T_optimizedCameras, NonconstIndexedAccessor< Vector3 > *optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), const bool onlyFrontObjectPoints=true, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
This function is a slow implementation and has been replaced by a faster implementation.
static bool optimizeObjectPointForFixedPoses(const AnyCamera &camera, const ConstIndexedAccessor< HomogenousMatrix4 > &world_T_cameras, const Vector3 &worldObjectPoint, const ConstIndexedAccessor< Vector2 > &imagePoints, Vector3 &optimizedWorldObjectPoint, const unsigned int iterations=5u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=10, const bool onlyFrontObjectPoints=true, Scalar *initialRobustError=nullptr, Scalar *finalRobustError=nullptr, Scalars *intermediateRobustErrors=nullptr)
Minimizes the projection errors for one given 3D object point, visible in several individual (fixed) ...
Definition: NonLinearOptimizationObjectPoint.h:759
static bool optimizeObjectPointsAndPoses(const ConstIndexedAccessor< const AnyCamera * > &cameras, const ConstIndexedAccessor< HomogenousMatrix4 > &world_T_cameras, const ConstIndexedAccessor< Vector3 > &objectPoints, const ObjectPointGroupsAccessor &correspondenceGroups, NonconstIndexedAccessor< HomogenousMatrix4 > *world_T_optimizedCameras, NonconstIndexedAccessor< Vector3 > *optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), const bool onlyFrontObjectPoints=true, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
Optimizes the locations of 3D object points visible in individual camera poses by minimizing the proj...
static bool optimizeObjectPointForFixedPosesIF(const ConstIndexedAccessor< const AnyCamera * > &cameras, const ConstIndexedAccessor< HomogenousMatrix4 > &flippedCameras_T_world, const Vector3 &worldObjectPoint, const ConstIndexedAccessor< Vector2 > &imagePoints, Vector3 &optimizedWorldObjectPoint, const unsigned int iterations=5u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=10, const bool onlyFrontObjectPoints=true, Scalar *initialRobustError=nullptr, Scalar *finalRobustError=nullptr, Scalars *intermediateRobustErrors=nullptr)
Minimizes the projection errors for one given 3D object point, visible in several individual (fixed) ...
static bool optimizeObjectPointsAndOrientationalPoses(const ConstIndexedAccessor< const AnyCamera * > &cameras, const ConstIndexedAccessor< HomogenousMatrix4 > &world_T_cameras, const ConstIndexedAccessor< Vector3 > &objectPoints, const ObjectPointGroupsAccessor &correspondenceGroups, NonconstIndexedAccessor< HomogenousMatrix4 > *world_T_optimizedCameras, NonconstIndexedAccessor< Vector3 > *optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), const bool onlyFrontObjectPoints=true, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
Optimizes the locations of 3D object points visible in individual camera poses by minimizing the proj...
static bool optimizeObjectPointForFixedOrientations(const AnyCamera &camera, const ConstIndexedAccessor< SquareMatrix3 > &world_R_cameras, const ConstIndexedAccessor< Vector2 > &imagePoints, const Vector3 &objectPoint, const Scalar objectPointDistance, Vector3 &optimizedObjectPoint, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), const bool onlyFrontObjectPoint=true, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
Optimizes the locations of one 3D object point visible in individual (fixed) camera poses all located...
Definition: NonLinearOptimizationObjectPoint.h:800
static bool optimizeObjectPointsAndOnePoseIF(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &firstPoseIF, const HomogenousMatrix4 &secondPoseIF, const ConstIndexedAccessor< Vector3 > &objectPoints, const ConstIndexedAccessor< Vector2 > &firstImagePoints, const ConstIndexedAccessor< Vector2 > &secondImagePoints, const bool useDistortionParameters, HomogenousMatrix4 *optimizedSecondPoseIF, NonconstIndexedAccessor< Vector3 > *optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), const bool onlyFrontObjectPoints=true, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
Optimizes the locations of 3D object points visible in two individual (inverted and flipped) camera p...
StaticMatrix< Scalar, 6, 6 > StaticMatrix6x6
Definition of a 6x6 matrix.
Definition: NonLinearOptimizationObjectPoint.h:53
static void optimizeObjectPointsForFixedPosesIFSubset(const PinholeCamera *pinholeCamera, const ConstIndexedAccessor< HomogenousMatrix4 > *invertedFlippedPoses, const ConstIndexedAccessor< Vector3 > *objectPoints, const ObjectPointGroupsAccessor *correspondenceGroups, const bool distortImagePoints, NonconstIndexedAccessor< Vector3 > *optimizedObjectPoints, const unsigned int iterations, const Estimator::EstimatorType estimator, Scalar lambda, const Scalar lambdaFactor, const bool onlyFrontObjectPoints, const unsigned int firstObjectPoint, const unsigned int numberObjectPoints)
Minimizes the projection errors of a subset of given 3D object points, visible in several individual ...
This class implements an accessor providing direct access to an array of elements.
Definition: Accessor.h:707
This class implements a base class for all indexed-based accessors allowing a non-constant reference ...
Definition: Accessor.h:284
NonconstIndexedAccessor< T > * pointer()
Returns the pointer to this object if this accessor holds at least one element (if this accessor is n...
Definition: Accessor.h:1710
This class implements a matrix with static dimensions.
Definition: StaticMatrix.h:34
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< HomogenousMatrix4 > HomogenousMatrices4
Definition of a vector holding HomogenousMatrix4 objects.
Definition: HomogenousMatrix4.h:73
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
PinholeCameraT< Scalar > PinholeCamera
Definition of an pinhole camera object with Scalar precision.
Definition: PinholeCamera.h:32
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15