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 * @return True, if succeeded
506 * @see optimizeObjectPointsAndPosesIF(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
507 */
508 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);
509
510 /**
511 * 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.
512 * The number of correspondences may vary between the individual frames (groups).<br>
513 * 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>
514 * This function performs a classic Bundle Adjustment using a per-session camera profile (the same identical camera profile for all individual images).
515 * @param camera The camera profile defining the projection for all camera frames, must be valid
516 * @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
517 * @param objectPoints The accessor for the known (but rough) locations of the 3D object points, defined in world
518 * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
519 * @param flippedOptimizedCameras_T_world Optional accessor for the resulting optimized camera poses, nullptr otherwise
520 * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
521 * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)s
522 * @param estimator Robust error estimator to be used
523 * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
524 * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
525 * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
526 * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
527 * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
528 * @param intermediateErrors Optional resulting intermediate (improving) errors
529 * @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
530 * @return True, if succeeded
531 * @see optimizeObjectPointsAndPoses(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
532 */
533 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);
534
535 /**
536 * 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.
537 * The number of correspondences may vary between the individual frames (groups).<br>
538 * 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>
539 * This function performs a classic Bundle Adjustment using a per-image camera profile (an individual camera profile for each individual image).
540 * @param cameras The camera profiles defining the projection, one for each camera frame, must be valid
541 * @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
542 * @param objectPoints The accessor for the known (but rough) locations of the 3D object points, defined in world
543 * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
544 * @param world_T_optimizedCameras Optional accessor for the resulting optimized camera poses, nullptr otherwise
545 * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
546 * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
547 * @param estimator Robust error estimator to be used
548 * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
549 * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
550 * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
551 * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
552 * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
553 * @param intermediateErrors Optional resulting intermediate (improving) errors
554 * @return True, if succeeded
555 * @see optimizeObjectPointsAndPosesIF(), optimizeObjectPointsAndOrientationalPoses(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
556 */
557 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);
558
559 /**
560 * 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.
561 * The number of correspondences may vary between the individual frames (groups).<br>
562 * 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.
563 * This function performs a classic Bundle Adjustment using a per-image camera profile (an individual camera profile for each individual image).
564 * @param cameras The camera profiles defining the projection, one for each camera frame, must be valid
565 * @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
566 * @param objectPoints The accessor for the known (but rough) locations of the 3D object points, defined in world
567 * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
568 * @param flippedOptimizedCameras_T_world Optional accessor for the resulting optimized camera poses, nullptr otherwise
569 * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
570 * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)s
571 * @param estimator Robust error estimator to be used
572 * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
573 * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
574 * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
575 * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
576 * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
577 * @param intermediateErrors Optional resulting intermediate (improving) errors
578 * @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
579 * @return True, if succeeded
580 * @see optimizeObjectPointsAndPoses(), optimizeObjectPointsAndOrientationalPosesIF(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
581 */
582 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);
583
584 /**
585 * 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.
586 * The number of correspondences may vary between the individual frames (groups).<br>
587 * 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>
588 * This function performs a Bundle Adjustment but does not modify the translations of camera poses.<br>
589 * The function supports a per-image camera profile (an individual camera profile for each individual image).
590 * @param cameras The camera profiles defining the projection, one for each camera frame, must be valid
591 * @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
592 * @param objectPoints The accessor for the known (but rough) locations of the 3D object points, defined in world
593 * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
594 * @param world_T_optimizedCameras Optional accessor for the resulting optimized camera poses, nullptr otherwise
595 * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
596 * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
597 * @param estimator Robust error estimator to be used
598 * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
599 * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
600 * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
601 * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
602 * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
603 * @param intermediateErrors Optional resulting intermediate (improving) errors
604 * @return True, if succeeded
605 * @see optimizeObjectPointsAndPoses(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
606 */
607 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);
608
609 /**
610 * 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.
611 * The number of correspondences may vary between the individual frames (groups).<br>
612 * 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.
613 * This function performs a Bundle Adjustment but does not modify the translations of camera poses.<br>
614 * The function supports a per-image camera profile (an individual camera profile for each individual image).
615 * @param cameras The camera profiles defining the projection, one for each camera frame, must be valid
616 * @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
617 * @param objectPoints The accessor for the known (but rough) locations of the 3D object points, defined in world
618 * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
619 * @param flippedOptimizedCameras_T_world Optional accessor for the resulting optimized camera poses, nullptr otherwise
620 * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
621 * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)s
622 * @param estimator Robust error estimator to be used
623 * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
624 * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
625 * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
626 * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
627 * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
628 * @param intermediateErrors Optional resulting intermediate (improving) errors
629 * @return True, if succeeded
630 * @see optimizeObjectPointsAndPosesIF(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
631 */
632 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);
633
634 protected:
635
636 /**
637 * This function is a slow implementation and has been replaced by a faster implementation.
638 * The code remains for demonstration and evaluation purposes.<br>
639 * 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>
640 * The number of correspondences may vary between the individual frames (groups).<br>
641 * 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.
642 * @param camera The camera profile defining the projection, must be valid
643 * @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
644 * @param objectPoints The accessor for the known (but rough) locations of the 3D object points, defined in world
645 * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
646 * @param world_T_optimizedCameras Optional accessor for the resulting optimized camera poses, nullptr otherwise
647 * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
648 * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
649 * @param estimator Robust error estimator to be used
650 * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
651 * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
652 * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
653 * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
654 * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
655 * @param intermediateErrors Optional resulting intermediate (improving) errors
656 * @return True, if succeeded
657 * @see optimizeObjectPointsAndPoses, optimizeObjectPointsAndPosesIF(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
658 */
659 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);
660
661 /**
662 * This function is a slow implementation and has been replaced by a faster implementation.
663 * The code remains for demonstration and evaluation purposes.<br>
664 * 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>
665 * The number of correspondences may vary between the individual frames (groups).<br>
666 * 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.
667 * @param camera The camera profile defining the projection, must be valid
668 * @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
669 * @param objectPoints The accessor for the known (but rough) locations of the 3D object points, defined in world
670 * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
671 * @param flippedOptimizedCameras_T_world Optional accessor for the resulting optimized camera poses, nullptr otherwise
672 * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
673 * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
674 * @param estimator Robust error estimator to be used
675 * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
676 * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
677 * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
678 * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
679 * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
680 * @param intermediateErrors Optional resulting intermediate (improving) errors
681 * @return True, if succeeded
682 * @see optimizeObjectPointsAndPosesIF, slowOptimizeObjectPointsAndPoses(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
683 */
684 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);
685
686 /**
687 * Deprecated.
688 *
689 * This function is a slow implementation and has been replaced by a faster implementation.
690 * The code remains for demonstration and evaluation purposes.<br>
691 * 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>
692 * The number of correspondences may vary between the individual frames (groups).<br>
693 * 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>
694 * @param pinholeCamera The pinhole camera profile defining the projection
695 * @param poses The accessor for the known (but rough) poses of the individual camera frames
696 * @param objectPoints The accessor for the known (but rough) locations of the 3D object points
697 * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
698 * @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
699 * @param optimizedPoses Optional accessor for the resulting optimized camera poses, nullptr otherwise
700 * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
701 * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
702 * @param estimator Robust error estimator to be used
703 * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
704 * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
705 * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
706 * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
707 * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
708 * @param intermediateErrors Optional resulting intermediate (improving) errors
709 * @return True, if succeeded
710 * @see optimizeObjectPointsAndPoses, optimizeObjectPointsAndPosesIF(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
711 */
712 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);
713
714 /**
715 * Deprecated.
716 *
717 * This function is a slow implementation and has been replaced by a faster implementation.
718 * The code remains for demonstration and evaluation purposes.<br>
719 * 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>
720 * The number of correspondences may vary between the individual frames (groups).<br>
721 * 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>
722 * @param pinholeCamera The pinhole camera profile defining the projection
723 * @param posesIF The accessor for the known (but rough) inverted and flipped poses of the individual camera frames
724 * @param objectPoints The accessor for the known (but rough) locations of the 3D object points
725 * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
726 * @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
727 * @param optimizedPosesIF Optional accessor for the resulting optimized camera poses, nullptr otherwise
728 * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object points locations, nullptr otherwise
729 * @param iterations Number of iterations to be applied at most, if no convergence can be reached, with range [1, infinity)
730 * @param estimator Robust error estimator to be used
731 * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
732 * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
733 * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
734 * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
735 * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
736 * @param intermediateErrors Optional resulting intermediate (improving) errors
737 * @return True, if succeeded
738 * @see optimizeObjectPointsAndPosesIF, slowOptimizeObjectPointsAndPoses(), NonLinearOptimization::ObjectPointToPoseIndexImagePointCorrespondenceAccessor.
739 */
740 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);
741
742 /**
743 * 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.
744 * Beware: The given inverted and flipped 6DOF poses are not equivalent to a standard extrinsic camera matrix.<br>
745 * @param pinholeCamera The pinhole camera object defining the projection between 3D object points and 2D image points
746 * @param invertedFlippedPoses The accessor for the known (and fixed) poses of the individual camera frames
747 * @param objectPoints The accessor for the known (but rough) locations of the 3D object points
748 * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image point location, one group for each object point
749 * @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
750 * @param optimizedObjectPoints Resulting optimized 3D object points, the caller must provide enough memory to store the optimized 3D points
751 * @param iterations Number of iterations to be applied at most, if no convergence can be reached
752 * @param estimator Robust error estimator to be used
753 * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
754 * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
755 * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
756 * @param firstObjectPoint The first object point to be handled
757 * @param numberObjectPoints The number of object points to be handled
758 * @see optimizeObjectPointsForFixedPosesIF().
759 */
760 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);
761};
762
763inline 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)
764{
766
767 return optimizeObjectPointForFixedPosesIF(anyCamera, ConstArrayAccessor<HomogenousMatrix4>(flippedCameras_T_world), worldObjectPoint, imagePoints, optimizedWorldObjectPoint, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialRobustError, finalRobustError, intermediateRobustErrors);
768}
769
770inline 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)
771{
772 const HomogenousMatrices4 flippedCameras_T_world(AnyCamera::standard2InvertedFlipped(Accessor::accessor2elements(world_T_cameras)));
773
774 return optimizeObjectPointForFixedPosesIF(cameras, ConstArrayAccessor<HomogenousMatrix4>(flippedCameras_T_world), worldObjectPoint, imagePoints, optimizedWorldObjectPoint, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialRobustError, finalRobustError, intermediateRobustErrors);
775}
776
777inline 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)
778{
779 const HomogenousMatrices4 flippedCamerasA_T_world(PinholeCamera::standard2InvertedFlipped(Accessor::accessor2elements(world_T_camerasA)));
780 const HomogenousMatrices4 flippedCamerasB_T_world(PinholeCamera::standard2InvertedFlipped(Accessor::accessor2elements(world_T_camerasB)));
781
782 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);
783}
784
785inline 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)
786{
787 ocean_assert(!poseAccessor.isEmpty() && !objectPoints.isEmpty());
788 ocean_assert(objectPoints.size() == correspondenceGroups.groups());
789
790 ocean_assert(lambda >= 0);
791 ocean_assert(lambdaFactor >= 1);
792
793 HomogenousMatrices4 invertedFlippedPoses;
794 invertedFlippedPoses.reserve(poseAccessor.size());
795
796 for (size_t n = 0; n < poseAccessor.size(); ++n)
797 {
798 invertedFlippedPoses.push_back(PinholeCamera::standard2InvertedFlipped(poseAccessor[n]));
799 }
800
801 return optimizeObjectPointsForFixedPosesIF(pinholeCamera, ConstArrayAccessor<HomogenousMatrix4>(invertedFlippedPoses), objectPoints, correspondenceGroups, distortImagePoints, optimizedObjectPoints, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, worker);
802}
803
804inline 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)
805{
806 SquareMatrices3 flippedCameras_R_world;
807 flippedCameras_R_world.reserve(world_R_cameras.size());
808
809 for (size_t n = 0; n < world_R_cameras.size(); ++n)
810 {
811 flippedCameras_R_world.emplace_back(AnyCamera::standard2InvertedFlipped(world_R_cameras[n]));
812 }
813
814 return optimizeObjectPointForFixedOrientationsIF(camera, ConstArrayAccessor<SquareMatrix3>(flippedCameras_R_world), imagePoints, objectPoint, objectPointDistance, optimizedObjectPoint, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoint, initialError, finalError, intermediateErrors);
815}
816
817inline 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)
818{
819 const HomogenousMatrix4 firstFlippedCamera_T_world(AnyCamera::standard2InvertedFlipped(world_T_firstCamera));
820 const HomogenousMatrix4 secondFlippedCamera_T_world(AnyCamera::standard2InvertedFlipped(world_T_secondCamera));
821
822 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))
823 {
824 return false;
825 }
826
827 if (world_T_optimizedSecondCamera != nullptr)
828 {
829 *world_T_optimizedSecondCamera = AnyCamera::invertedFlipped2Standard(*world_T_optimizedSecondCamera);
830 }
831
832 return true;
833}
834
835inline 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)
836{
838 const HomogenousMatrix4 secondPoseIF(PinholeCamera::standard2InvertedFlipped(secondPose));
839
840 if (!optimizeObjectPointsAndTwoPosesIF(pinholeCamera, firstPoseIF, secondPoseIF, objectPoints, firstImagePoints, secondImagePoints, useDistortionParameters, optimizedFirstPose, optimizedSecondPose, optimizedObjectPoints, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialError, finalError, invertedFirstCovariances, invertedSecondCovariances, intermediateErrors))
841 {
842 return false;
843 }
844
845 if (optimizedFirstPose)
846 {
847 *optimizedFirstPose = PinholeCamera::invertedFlipped2Standard(*optimizedFirstPose);
848 }
849
850 if (optimizedSecondPose)
851 {
852 *optimizedSecondPose = PinholeCamera::invertedFlipped2Standard(*optimizedSecondPose);
853 }
854
855 return true;
856}
857
858inline 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)
859{
860#if 1
861 // creating local pointer to avoid Clang compiler bug
862 const AnyCamera* cameraPointer = &camera;
863 const ConstElementAccessor<const AnyCamera*> cameraAccessor(world_T_cameras.size(), cameraPointer);
864#else
865 const ConstElementAccessor<const AnyCamera*> cameraAccessor(world_T_cameras.size(), &camera);
866#endif
867
868 const HomogenousMatrices4 flippedCameras_T_world(AnyCamera::standard2InvertedFlipped(Accessor::accessor2elements(world_T_cameras)));
869
870 HomogenousMatrices4 flippedOptimizedCameras_T_world;
871 NonconstArrayAccessor<HomogenousMatrix4> accessor_flippedOptimizedCameras_T_world(flippedOptimizedCameras_T_world, world_T_optimizedCameras ? world_T_cameras.size() : 0);
872
873 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))
874 {
875 return false;
876 }
877
878 if (world_T_optimizedCameras != nullptr)
879 {
880 for (size_t n = 0; n < flippedOptimizedCameras_T_world.size(); ++n)
881 {
882 (*world_T_optimizedCameras)[n] = AnyCamera::invertedFlipped2Standard(flippedOptimizedCameras_T_world[n]);
883 }
884 }
885
886 return true;
887}
888
889inline 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)
890{
891#if 1
892 // creating local pointer to avoid Clang compiler bug
893 const AnyCamera* cameraPointer = &camera;
894 const ConstElementAccessor<const AnyCamera*> cameraAccessor(flippedCameras_T_world.size(), cameraPointer);
895#else
896 const ConstElementAccessor<const AnyCamera*> cameraAccessor(flippedCameras_T_world.size(), &camera);
897#endif
898
899 return optimizeObjectPointsAndPosesIF(cameraAccessor, flippedCameras_T_world, objectPoints, correspondenceGroups, flippedOptimizedCameras_T_world, optimizedObjectPoints, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialError, finalError, intermediateErrors, gravityConstraints);
900}
901
902inline 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)
903{
904 const AnyCameraPinhole anyCameraPinhole(PinholeCamera(camera, useDistortionParameters));
905
906 return slowOptimizeObjectPointsAndPoses(anyCameraPinhole, poses, objectPoints, correspondenceGroups, optimizedPoses, optimizedObjectPoints, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialError, finalError, intermediateErrors);
907}
908
909inline 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)
910{
911 const AnyCameraPinhole anyCameraPinhole(PinholeCamera(camera, useDistortionParameters));
912
913 return slowOptimizeObjectPointsAndPosesIF(anyCameraPinhole, posesIF, objectPoints, correspondenceGroups, optimizedPosesIF, optimizedObjectPoints, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialError, finalError, intermediateErrors);
914}
915
916
917}
918
919}
920
921#endif // META_OCEAN_GEOMETRY_NON_LINEAR_OPTIMIZATION_OBJECT_POINT_H
virtual size_t size() const =0
Returns the number of accessible elements of this accessor object.
bool isEmpty() const
Returns whether this accessor provides no elements.
Definition Accessor.h:1578
static std::vector< typename TAccessor::Type > accessor2elements(const TAccessor &accessor)
Returns all elements of a given accessor (as a block).
Definition Accessor.h:1584
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:130
This class implements a specialized AnyCamera object wrapping the actual camera model.
Definition AnyCamera.h:597
static HomogenousMatrixT4< U > standard2InvertedFlipped(const HomogenousMatrixT4< U > &world_T_camera)
Transforms a standard homogenous 4x4 viewing (extrinsic camera) matrix into an inverted and flipped c...
Definition Camera.h:734
static HomogenousMatrixT4< U > invertedFlipped2Standard(const HomogenousMatrixT4< U > &flippedCamera_T_world)
Transforms an inverted and flipped camera pose into a standard camera pose.
Definition Camera.h:757
This class implements an accessor providing direct access to a constant array of elements.
Definition Accessor.h:400
This class implements an accessor providing direct access to a constant array of elements while all e...
Definition Accessor.h:942
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:785
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:817
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:835
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:777
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 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)
Optimizes the locations of 3D object points visible in individual (inverted and flipped) camera poses...
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 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:763
static bool optimizeObjectPointsAndPoses(const ConstIndexedAccessor< const AnyCamera * > &cameras, const ConstIndexedAccessor< HomogenousMatrix4 > &world_T_cameras, const ConstIndexedAccessor< Vector3 > &objectPoints, const ObjectPointGroupsAccessor &correspondenceGroups, NonconstIndexedAccessor< HomogenousMatrix4 > *world_T_optimizedCameras, NonconstIndexedAccessor< Vector3 > *optimizedObjectPoints, const unsigned int iterations, const Geometry::Estimator::EstimatorType estimator=Geometry::Estimator::ET_SQUARE, const Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), const bool onlyFrontObjectPoints=true, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
Optimizes the locations of 3D object points visible in individual camera poses by minimizing the proj...
static bool 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)
Optimizes the locations of 3D object points visible in individual (inverted and flipped) camera poses...
Definition NonLinearOptimizationObjectPoint.h:889
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:804
std::vector< StaticMatrix3x3 > StaticMatrices3x3
Definition of a vector holding 3x3 matrices.
Definition NonLinearOptimizationObjectPoint.h:59
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)
Optimizes the locations of 3D object points visible in individual camera poses by minimizing the proj...
Definition NonLinearOptimizationObjectPoint.h:858
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
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< Scalar > Scalars
Definition of a vector holding Scalar objects.
Definition Math.h:145
std::vector< SquareMatrix3 > SquareMatrices3
Definition of a vector holding SquareMatrix3 objects.
Definition SquareMatrix3.h:72
PinholeCameraT< Scalar > PinholeCamera
Definition of an pinhole camera object with Scalar precision.
Definition PinholeCamera.h:39
The namespace covering the entire Ocean framework.
Definition Accessor.h:15