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