Ocean
Loading...
Searching...
No Matches
NonLinearOptimizationCamera.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_CAMERA_H
9#define META_OCEAN_GEOMETRY_NON_LINEAR_OPTIMIZATION_CAMERA_H
10
13
17
18namespace Ocean
19{
20
21namespace Geometry
22{
23
24/**
25 * This class implements least square or robust optimization algorithms for camera profiles.
26 * @ingroup geometry
27 */
28class OCEAN_GEOMETRY_EXPORT NonLinearOptimizationCamera : protected NonLinearOptimization
29{
30 protected:
31
32 /**
33 * Forward declaration of a base data class necessary to optimize rotational camera motion.
34 */
35 class CameraOrientationsBaseData;
36
37 /**
38 * Forward declaration of a base class allowing to optimized the camera profile.
39 * @tparam tParameters The number of parameters to optimized
40 */
41 template <unsigned int tParameters>
43
44 /**
45 * Forward declaration of the data class allowing to find an initial camera field of view for rotational camera motion.
46 */
47 class CameraOrientationsFovData;
48
49 /**
50 * Forward declaration of an optimization provider allowing to optimize the individual parameters of a camera profile.
51 * @tparam tOptimizationStrategy The optimization strategy to be used
52 */
53 template <PinholeCamera::OptimizationStrategy tOptimizationStrategy>
55
56 /**
57 * Forward declaration of the data class allowing to optimized the camera parameters for rotational camera motion.
58 * @tparam tParameters The number of parameters to optimized
59 */
60 template <unsigned int tParameters>
62
63 /**
64 * Forward declaration of an optimization provider allowing to optimize a camera profile and camera poses concurrently.
65 */
66 class CameraPosesOptimizationProvider;
67
68 /**
69 * Forward declaration of the data class allowing to optimized the camera parameters for unconstrained (translational and rotational) camera motion.
70 * @tparam tParameters The number of parameters to optimized
71 */
72 template <unsigned int tParameters>
74
75 public:
76
77 /**
78 * Determines the initial field of view for a set of camera frames with known orientations and groups of correspondences of ids of 3D object points and 2D image point locations from the individual frames.
79 * The number of correspondences may vary between the individual frames (groups).<br>
80 * 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>
81 * @param pinholeCamera The pinhole camera profile for which the better field of view will be determined, must be valid
82 * @param orientations The accessor for the known orientations of the individual camera frames
83 * @param correspondenceGroups The accessor for the individual groups of point correspondences, one group for each orientation
84 * @param optimizedCamera The resulting camera profile with best matching field of view
85 * @param optimizedOrientations Optional accessor for the optimized camera orientations matching with the new camera profile
86 * @param lowerFovX The lower bound of the possible horizontal field of view in radian, with range (0, upperFovX]
87 * @param upperFovX The upper bound of the possible horizontal field of view in radian, with range [lowerFovX, PI)
88 * @param steps The number of steps in which the defined angle range is subdivided, with range [4, infinity)
89 * @param recursiveIterations The number of recursive iterations that will be applied to improve the accuracy, start with the second iteration the search for the best fov is centered at the position of the previous iteration, with range [1, infinity)
90 * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
91 * @param significantResult Optional resulting whether the resulting field of view has an significant impact on the error; True, of so
92 * @param finalError Optional resulting averaged square pixel error for the camera profile with the best matching field of view
93 * @param worker Optional worker object to distribute the computation
94 * @param abort Optional abort statement allowing to stop the execution; True, if the execution has to stop
95 * @return True, if succeeded and the execution has not been aborted
96 */
97 static bool findInitialFieldOfView(const PinholeCamera& pinholeCamera, const ConstIndexedAccessor<SquareMatrix3>& orientations, const PoseGroupsAccessor& correspondenceGroups, PinholeCamera& optimizedCamera, NonconstIndexedAccessor<SquareMatrix3>* optimizedOrientations, const Scalar lowerFovX = Numeric::deg2rad(40), const Scalar upperFovX = Numeric::deg2rad(90), const unsigned int steps = 10u, const unsigned int recursiveIterations = 3u, const bool onlyFrontObjectPoints = true, bool* significantResult = nullptr, Scalar* finalError = nullptr, Worker* worker = nullptr, bool* abort = nullptr);
98
99 /**
100 * Determines the initial field of view for a set of camera frames with known poses and groups of correspondences between pose indices and 2D image points locations within the pose frames while also the provided object points are optimized.
101 * The number of correspondences may vary between the individual frames (groups).<br>
102 * 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>
103 * @param pinholeCamera The pinhole camera profile for which the better field of view will be determined, must be valid
104 * @param poses The accessor for the known poses of the individual camera frames
105 * @param objectPoints The accessor for the individual 3D object points
106 * @param correspondenceGroups The accessor for the individual groups of correspondences between pose ids and image point location, one group for each object point
107 * @param optimizedCamera The resulting camera profile with best matching field of view
108 * @param optimizedPoses Optional accessor for the resulting optimized camera poses matching with the new camera profile
109 * @param optimizedObjectPoints Optional accessor for the resulting optimized object point locations
110 * @param lowerFovX The lower bound of the possible horizontal field of view in radian, with range (0, upperFovX]
111 * @param upperFovX The upper bound of the possible horizontal field of view in radian, with range [lowerFovX, PI)
112 * @param steps The number of steps in which the defined angle range is subdivided, with range [4, infinity)
113 * @param recursiveIterations The number of recursive iterations that will be applied to improve the accuracy, start with the second iteration the search for the best fov is centered at the position of the previous iteration, with range [1, infinity)
114 * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
115 * @param significantResult Optional resulting whether the resulting field of view has an significant impact on the error; True, of so
116 * @param finalError Optional resulting averaged square pixel error for the camera profile with the best matching field of view
117 * @param worker Optional worker object to distribute the computation
118 * @param abort Optional abort statement allowing to stop the execution; True, if the execution has to stop
119 * @return True, if succeeded and the execution has not been aborted
120 */
121 static bool findInitialFieldOfView(const PinholeCamera& pinholeCamera, const ConstIndexedAccessor<HomogenousMatrix4>& poses, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, PinholeCamera& optimizedCamera, NonconstIndexedAccessor<HomogenousMatrix4>* optimizedPoses, NonconstIndexedAccessor<Vector3>* optimizedObjectPoints, const Scalar lowerFovX = Numeric::deg2rad(40), const Scalar upperFovX = Numeric::deg2rad(90), const unsigned int steps = 10u, const unsigned int recursiveIterations = 3u, const bool onlyFrontObjectPoints = true, bool* significantResult = nullptr, Scalar* finalError = nullptr, Worker* worker = nullptr, bool* abort = nullptr);
122
123 /**
124 * Optimizes the individual parameters of a camera profile by minimizing the pixel error between normalized image points (projected 3D object points) and their corresponding 2D image point observations.
125 * Which parameter of the camera profile will be optimized depends on the specified optimization strategy.
126 * @param pinholeCamera The pinhole camera profile with initial distortion parameters to optimize
127 * @param normalizedObjectPoints The accessor for the projected 3D object points (the normalized image/object points)
128 * @param imagePoints imagePoints The accessor for the observations of the projected 3D object points, defined in the pixel coordinate system, each point corresponds to one normalized object point
129 * @param optimizationStrategy The optimization strategy to be used
130 * @param optimizedCamera Resulting optimized camera object holding optimized intrinsic and distortion parameters
131 * @param iterations Number of iterations to be applied at most, if no convergence can be reached
132 * @param estimator Robust error estimator to be used
133 * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
134 * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
135 * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
136 * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
137 * @return True, if succeeded
138 */
139 static bool optimizeCamera(const PinholeCamera& pinholeCamera, const ConstIndexedAccessor<Vector2>& normalizedObjectPoints, const ConstIndexedAccessor<Vector2>& imagePoints, const PinholeCamera::OptimizationStrategy optimizationStrategy, PinholeCamera& optimizedCamera, const unsigned int iterations = 20u, const Estimator::EstimatorType estimator = Estimator::ET_SQUARE, Scalar lambda = Scalar(0.001), const Scalar lambdaFactor = Scalar(5), Scalar* initialError = nullptr, Scalar* finalError = nullptr);
140
141 /**
142 * Optimizes the camera parameters of a given camera profile for a set of camera frames with known orientation and groups of 2D/3D point correspondences from individual frames.
143 * The number of points correspondences may vary between the individual frames (groups).<br>
144 * Each group may address individual object points.<br>
145 * @param pinholeCamera The pinhole camera profile to optimized
146 * @param orientations The accessor for the known orientations of the individual camera frames
147 * @param correspondenceGroups The accessor for the individual groups of point correspondences, one group for each orientation
148 * @param optimizationStrategy The optimization strategy
149 * @param optimizedCamera The resulting camera profile with ideal field of view
150 * @param optimizedOrientations Optional accessor for the optimized camera orientations matching with the new camera profile
151 * @param iterations Number of iterations to be applied at most, if no convergence can be reached
152 * @param estimator Robust error estimator to be used
153 * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
154 * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
155 * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
156 * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
157 * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
158 * @param intermediateErrors Optional resulting intermediate averaged pixel errors for the individual optimization steps, in relation to the defined estimator
159 * @return True, if succeeded
160 */
161 static bool optimizeCameraOrientations(const PinholeCamera& pinholeCamera, const ConstIndexedAccessor<SquareMatrix3>& orientations, const PoseGroupsAccessor& correspondenceGroups, const PinholeCamera::OptimizationStrategy optimizationStrategy, PinholeCamera& optimizedCamera, NonconstIndexedAccessor<SquareMatrix3>* optimizedOrientations, 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);
162
163 /**
164 * Minimizes the projection error between the projections of static 3D object points and their corresponding image points in several 6DOF camera poses.
165 * The camera profile as well as the camera poses are optimized concurrently.
166 * The given poses are equivalent to extrinsic camera matrices and thus define a transformation from the camera coordinate system into the world coordinate system.<br>
167 * @param pinholeCamera The pinhole camera holding intrinsic and distortion parameters to minimize the projection error for
168 * @param poses The individual camera poses, one pose for each pair of groups of object points and image points
169 * @param objectPointGroups The accessor for the individual groups of 3D object points, one group for each camera pose with at least one object point
170 * @param imagePointGroups The accessor for the individual groups of 2D image points, one group for each camera pose and one image point for each corresponding object point
171 * @param optimizedCamera The resulting optimized camera profile
172 * @param optimizedPoses Optional accessor for the resulting optimized camera poses, matching with the new camera profile
173 * @param iterations Number of iterations to be applied at most, if no convergence can be reached
174 * @param estimator Robust error estimator to be used
175 * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
176 * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
177 * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
178 * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
179 * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
180 * @param intermediateErrors Optional resulting intermediate averaged pixel errors for the individual optimization steps, in relation to the defined estimator
181 * @return True, if succeeded
182 * @see optimizeCameraPoseIF().
183 */
184 static bool optimizeCameraPoses(const PinholeCamera& pinholeCamera, const ConstIndexedAccessor<HomogenousMatrix4>& poses, const ConstIndexedAccessor<Vectors3>& objectPointGroups, const ConstIndexedAccessor<Vectors2>& imagePointGroups, PinholeCamera& optimizedCamera, NonconstIndexedAccessor<HomogenousMatrix4>* optimizedPoses, 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, Scalars* intermediateErrors = nullptr);
185
186 /**
187 * Minimizes the projection error between the projections of static 3D object points and their corresponding image points in several 6DOF camera poses.
188 * Beware: The given poses are not equivalent to extrinsic camera matrices.<br>
189 * The given poses must be inverted and flipped around the new x axis by 180 degree.<br>
190 * @see optimizeCameraPose().
191 */
192 static bool optimizeCameraPosesIF(const PinholeCamera& pinholeCamera, const ConstIndexedAccessor<HomogenousMatrix4>& posesIF, const ConstIndexedAccessor<Vectors3>& objectPointGroups, const ConstIndexedAccessor<Vectors2>& imagePointGroups, PinholeCamera& optimizedCamera, NonconstIndexedAccessor<HomogenousMatrix4>* optimizedPosesIF, 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, Scalars* intermediateErrors = nullptr);
193
194 /**
195 * Optimizes the camera parameters of a given camera profile for a set of given camera poses and a set of given 3D object points by minimizing the projection error between the 3D object points and the corresponding 2D image points.
196 * This function also optimized the camera poses and the locations of the 3D object point while the camera profile is optimized.<br>
197 * The number of 2D/3D point correspondences may vary between the individual frames (groups).<br>
198 * 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>
199 * @param pinholeCamera The pinhole camera profile to optimized
200 * @param poses The accessor for the known poses of the individual camera frames
201 * @param objectPoints The accessor for the known 3D object points locations
202 * @param correspondenceGroups The accessor for the individual groups of correspondences between pose indices and image points, one group for each object point
203 * @param optimizationStrategy The optimization strategy for the camera profile
204 * @param optimizedCamera The resulting optimized camera profile
205 * @param optimizedPoses Optional accessor for the resulting optimized camera poses, matching with the new camera profile
206 * @param optimizedObjectPoints Optional accessor for the resulting optimized 3D object point locations, matching with the new camera profile
207 * @param iterations Number of iterations to be applied at most, if no convergence can be reached
208 * @param estimator Robust error estimator to be used
209 * @param lambda Initial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
210 * @param lambdaFactor Levenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
211 * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
212 * @param initialError Optional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
213 * @param finalError Optional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
214 * @param intermediateErrors Optional resulting intermediate averaged pixel errors for the individual optimization steps, in relation to the defined estimator
215 * @return True, if succeeded
216 */
217 static bool optimizeCameraObjectPointsPoses(const PinholeCamera& pinholeCamera, const ConstIndexedAccessor<HomogenousMatrix4>& poses, const ConstIndexedAccessor<Vector3>& objectPoints, const ObjectPointGroupsAccessor& correspondenceGroups, const PinholeCamera::OptimizationStrategy optimizationStrategy, PinholeCamera& optimizedCamera, 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);
218
219 protected:
220
221 /**
222 * Determines the initial field of view for a set of camera frames with known orientations and groups of correspondences of ids of 3D object points and 2D image point locations from the individual frames.
223 * The number of correspondences may vary between the individual frames (groups).<br>
224 * 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.
225 * @param pinholeCamera The pinhole camera profile for which the better field of view will be determined, must be valid
226 * @param orientations The accessor for the known orientations of the individual camera frames
227 * @param correspondenceGroups The accessor for the individual groups of point correspondences, one group for each orientation
228 * @param optimizedCamera The resulting camera profile with best matching field of view
229 * @param optimizedOrientations Optional accessor for the optimized camera orientations matching with the new camera profile
230 * @param lowerFovX The lower bound of the possible horizontal field of view in radian, with range (0, upperFovX]
231 * @param upperFovX The upper bound of the possible horizontal field of view in radian, with range [lowerFovX, PI)
232 * @param overallSteps The overall number of steps in which the defined angle range is subdivided, with range [4, infinity)
233 * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
234 * @param bestError Resulting averaged square pixel error for the camera profile with the best matching field of view
235 * @param allErrors Optional vector of all errors that have been determined (can be used to decide whether a resulting best camera profile is significantly different from all other camera profiles)
236 * @param lock Lock object, must be defined if this function is executed in parallel on individual threads, nullptr otherwise
237 * @param abort Optional abort statement allowing to stop the execution; True, if the execution has to stop
238 * @param firstStep The first step to be handled, with range [0, overallSteps)
239 * @param steps The number of steps which will be handled (from the entire number of overall steps), with range [1, overallSteps]
240 */
241 static void findInitialFieldOfViewSubset(const PinholeCamera* pinholeCamera, const ConstIndexedAccessor<SquareMatrix3>* orientations, const PoseGroupsAccessor* correspondenceGroups, PinholeCamera* optimizedCamera, SquareMatrices3* optimizedOrientations, const Scalar lowerFovX, const Scalar upperFovX, const unsigned int overallSteps, const bool onlyFrontObjectPoints, Scalar* bestError, Scalars* allErrors, Lock* lock, bool* abort, const unsigned int firstStep, const unsigned int steps);
242
243 /**
244 * Determines the initial field of view for a set of camera frames with known poses and groups of correspondences between pose indices and 2D image points locations within the pose frames.
245 * The number of correspondences may vary between the individual frames (groups).<br>
246 * 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>
247 * @param pinholeCamera The pinhole camera profile for which the better field of view will be determined, must be valid
248 * @param poses The accessor for the known poses of the individual camera frames
249 * @param objectPoints The accessor for the individual 3D object points
250 * @param correspondenceGroups The accessor for the individual groups of correspondences between pose ids and image point location, one group for each object point
251 * @param optimizedCamera The resulting camera profile with best matching field of view
252 * @param optimizedPoses Optional accessor for the resulting optimized camera poses matching with the new camera profile
253 * @param optimizedObjectPoints Optional accessor for the resulting optimized object point locations
254 * @param lowerFovX The lower bound of the possible horizontal field of view in radian, with range (0, upperFovX]
255 * @param upperFovX The upper bound of the possible horizontal field of view in radian, with range [lowerFovX, PI)
256 * @param overallSteps The overall number of steps in which the defined angle range is subdivided, with range [4, infinity)
257 * @param onlyFrontObjectPoints True, to avoid that the optimized 3D position lies behind any camera
258 * @param bestError Resulting averaged square pixel error for the camera profile with the best matching field of view
259 * @param allErrors Optional vector of all errors that have been determined (can be used to decide whether a resulting best camera profile is significantly different from all other camera profiles)
260 * @param lock Lock object, must be defined if this function is executed in parallel on individual threads, nullptr otherwise
261 * @param abort Optional abort statement allowing to stop the execution; True, if the execution has to stop
262 * @param firstStep The first step to be handled, with range [0, overallSteps)
263 * @param steps The number of steps which will be handled (from the entire number of overall steps), with range [1, overallSteps]
264 */
265 static void findInitialFieldOfViewSubset(const PinholeCamera* pinholeCamera, const ConstIndexedAccessor<HomogenousMatrix4>* poses, const ConstIndexedAccessor<Vector3>* objectPoints, const ObjectPointGroupsAccessor* correspondenceGroups, PinholeCamera* optimizedCamera, HomogenousMatrices4* optimizedPoses, Vectors3* optimizedObjectPoints, const Scalar lowerFovX, const Scalar upperFovX, const unsigned int overallSteps, const bool onlyFrontObjectPoints, Scalar* bestError, Scalars* allErrors, Lock* lock, bool* abort, const unsigned int firstStep, const unsigned int steps);
266};
267
268}
269
270}
271
272#endif // META_OCEAN_GEOMETRY_NON_LINEAR_OPTIMIZATION_CAMERA_H
This class implements a base class for all indexed-based accessors allowing a constant reference acce...
Definition Accessor.h:241
EstimatorType
Definition of individual robust estimator types.
Definition Estimator.h:34
This class implements an abstract specialization of the accessor for groups of pairs for object point...
Definition NonLinearOptimization.h:159
This class implements an abstract specialization of the accessor for groups of pairs for poses.
Definition NonLinearOptimization.h:185
Forward declaration of the data class allowing to optimized the camera parameters for unconstrained (...
Definition NonLinearOptimizationCamera.h:73
Forward declaration of the data class allowing to optimized the camera parameters for rotational came...
Definition NonLinearOptimizationCamera.h:61
Forward declaration of a base class allowing to optimized the camera profile.
Definition NonLinearOptimizationCamera.h:42
Forward declaration of an optimization provider allowing to optimize the individual parameters of a c...
Definition NonLinearOptimizationCamera.h:54
This class implements least square or robust optimization algorithms for camera profiles.
Definition NonLinearOptimizationCamera.h:29
static bool optimizeCameraPoses(const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< HomogenousMatrix4 > &poses, const ConstIndexedAccessor< Vectors3 > &objectPointGroups, const ConstIndexedAccessor< Vectors2 > &imagePointGroups, PinholeCamera &optimizedCamera, NonconstIndexedAccessor< HomogenousMatrix4 > *optimizedPoses, 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, Scalars *intermediateErrors=nullptr)
Minimizes the projection error between the projections of static 3D object points and their correspon...
static bool optimizeCameraObjectPointsPoses(const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< HomogenousMatrix4 > &poses, const ConstIndexedAccessor< Vector3 > &objectPoints, const ObjectPointGroupsAccessor &correspondenceGroups, const PinholeCamera::OptimizationStrategy optimizationStrategy, PinholeCamera &optimizedCamera, 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)
Optimizes the camera parameters of a given camera profile for a set of given camera poses and a set o...
static bool findInitialFieldOfView(const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< HomogenousMatrix4 > &poses, const ConstIndexedAccessor< Vector3 > &objectPoints, const ObjectPointGroupsAccessor &correspondenceGroups, PinholeCamera &optimizedCamera, NonconstIndexedAccessor< HomogenousMatrix4 > *optimizedPoses, NonconstIndexedAccessor< Vector3 > *optimizedObjectPoints, const Scalar lowerFovX=Numeric::deg2rad(40), const Scalar upperFovX=Numeric::deg2rad(90), const unsigned int steps=10u, const unsigned int recursiveIterations=3u, const bool onlyFrontObjectPoints=true, bool *significantResult=nullptr, Scalar *finalError=nullptr, Worker *worker=nullptr, bool *abort=nullptr)
Determines the initial field of view for a set of camera frames with known poses and groups of corres...
static bool optimizeCamera(const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< Vector2 > &normalizedObjectPoints, const ConstIndexedAccessor< Vector2 > &imagePoints, const PinholeCamera::OptimizationStrategy optimizationStrategy, PinholeCamera &optimizedCamera, const unsigned int iterations=20u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr)
Optimizes the individual parameters of a camera profile by minimizing the pixel error between normali...
static void findInitialFieldOfViewSubset(const PinholeCamera *pinholeCamera, const ConstIndexedAccessor< HomogenousMatrix4 > *poses, const ConstIndexedAccessor< Vector3 > *objectPoints, const ObjectPointGroupsAccessor *correspondenceGroups, PinholeCamera *optimizedCamera, HomogenousMatrices4 *optimizedPoses, Vectors3 *optimizedObjectPoints, const Scalar lowerFovX, const Scalar upperFovX, const unsigned int overallSteps, const bool onlyFrontObjectPoints, Scalar *bestError, Scalars *allErrors, Lock *lock, bool *abort, const unsigned int firstStep, const unsigned int steps)
Determines the initial field of view for a set of camera frames with known poses and groups of corres...
static bool findInitialFieldOfView(const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< SquareMatrix3 > &orientations, const PoseGroupsAccessor &correspondenceGroups, PinholeCamera &optimizedCamera, NonconstIndexedAccessor< SquareMatrix3 > *optimizedOrientations, const Scalar lowerFovX=Numeric::deg2rad(40), const Scalar upperFovX=Numeric::deg2rad(90), const unsigned int steps=10u, const unsigned int recursiveIterations=3u, const bool onlyFrontObjectPoints=true, bool *significantResult=nullptr, Scalar *finalError=nullptr, Worker *worker=nullptr, bool *abort=nullptr)
Determines the initial field of view for a set of camera frames with known orientations and groups of...
static void findInitialFieldOfViewSubset(const PinholeCamera *pinholeCamera, const ConstIndexedAccessor< SquareMatrix3 > *orientations, const PoseGroupsAccessor *correspondenceGroups, PinholeCamera *optimizedCamera, SquareMatrices3 *optimizedOrientations, const Scalar lowerFovX, const Scalar upperFovX, const unsigned int overallSteps, const bool onlyFrontObjectPoints, Scalar *bestError, Scalars *allErrors, Lock *lock, bool *abort, const unsigned int firstStep, const unsigned int steps)
Determines the initial field of view for a set of camera frames with known orientations and groups of...
static bool optimizeCameraOrientations(const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< SquareMatrix3 > &orientations, const PoseGroupsAccessor &correspondenceGroups, const PinholeCamera::OptimizationStrategy optimizationStrategy, PinholeCamera &optimizedCamera, NonconstIndexedAccessor< SquareMatrix3 > *optimizedOrientations, 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 camera parameters of a given camera profile for a set of camera frames with known orien...
static bool optimizeCameraPosesIF(const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< HomogenousMatrix4 > &posesIF, const ConstIndexedAccessor< Vectors3 > &objectPointGroups, const ConstIndexedAccessor< Vectors2 > &imagePointGroups, PinholeCamera &optimizedCamera, NonconstIndexedAccessor< HomogenousMatrix4 > *optimizedPosesIF, 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, Scalars *intermediateErrors=nullptr)
Minimizes the projection error between the projections of static 3D object points and their correspon...
This class implements the basic functions for least square or robust optimization algorithms for non ...
Definition NonLinearOptimization.h:34
This class implements a recursive lock object.
Definition Lock.h:31
This class implements a base class for all indexed-based accessors allowing a non-constant reference ...
Definition Accessor.h:284
OptimizationStrategy
Definition of individual optimization strategies for camera parameters.
Definition PinholeCamera.h:129
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
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition Vector3.h:65
The namespace covering the entire Ocean framework.
Definition Accessor.h:15