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