Ocean
Loading...
Searching...
No Matches
Ocean::Geometry::NonLinearOptimizationCamera Class Reference

This class implements least square or robust optimization algorithms for camera profiles. More...

#include <NonLinearOptimizationCamera.h>

Inheritance diagram for Ocean::Geometry::NonLinearOptimizationCamera:

Data Structures

class  CameraObjectPointsPosesData
 Forward declaration of the data class allowing to optimized the camera parameters for unconstrained (translational and rotational) camera motion. More...
 
class  CameraOrientationsData
 Forward declaration of the data class allowing to optimized the camera parameters for rotational camera motion. More...
 
class  CameraProfileBaseData
 Forward declaration of a base class allowing to optimized the camera profile. More...
 
class  CameraProvider
 Forward declaration of an optimization provider allowing to optimize the individual parameters of a camera profile. More...
 

Public Types

enum  OptimizationStrategy : uint32_t {
  OS_INVALID = 0u , OS_ONLY_FOCAL_LENGTH , OS_UP_TO_PRINCIPAL_POINT_AFTER_ANOTHER , OS_UP_TO_MAJOR_DISTORTION_AFTER_ANOTHER ,
  OS_ALL_PARAMETERS_AT_ONCE , OS_ALL_PARAMETERS_AFTER_ANOTHER
}
 Definition of individual optimization strategies for how the camera parameters can be optimized. More...
 

Static Public Member Functions

static bool findInitialFieldOfView (const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< SquareMatrix3 > &world_R_cameras, const PoseGroupsAccessor &correspondenceGroups, PinholeCamera &optimizedCamera, NonconstIndexedAccessor< SquareMatrix3 > *world_R_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 correspondences of ids of 3D object points and 2D image point locations from the individual frames.
 
static bool findInitialFieldOfView (const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< HomogenousMatrix4 > &world_T_cameras, const ConstIndexedAccessor< Vector3 > &objectPoints, const ObjectPointGroupsAccessor &correspondenceGroups, PinholeCamera &optimizedCamera, NonconstIndexedAccessor< HomogenousMatrix4 > *world_T_optimizedCameras, 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 correspondences between pose indices and 2D image points locations within the pose frames while also the provided object points are optimized.
 
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 normalized image points (projected 3D object points) and their corresponding 2D image point observations.
 
static bool optimizeCameraOrientations (const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< SquareMatrix3 > &world_R_cameras, const PoseGroupsAccessor &correspondenceGroups, const PinholeCamera::OptimizationStrategy optimizationStrategy, PinholeCamera &optimizedCamera, NonconstIndexedAccessor< SquareMatrix3 > *world_R_optimizedCameras, 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 orientation and groups of 2D/3D point correspondences from individual frames.
 
static bool optimizeCameraPoses (const AnyCamera &camera, const ConstIndexedAccessor< HomogenousMatrix4 > &world_T_cameras, const ConstIndexedAccessor< Vectors3 > &objectPointGroups, const ConstIndexedAccessor< Vectors2 > &imagePointGroups, SharedAnyCamera &optimizedCamera, NonconstIndexedAccessor< HomogenousMatrix4 > *world_T_optimizedCameras, const unsigned int iterations, const OptimizationStrategy optimizationStrategy=OS_ALL_PARAMETERS_AFTER_ANOTHER, 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 corresponding image points in several 6DOF camera poses.
 
static bool optimizeCameraPosesIF (const AnyCamera &camera, const ConstIndexedAccessor< HomogenousMatrix4 > &flippedCameras_T_world, const ConstIndexedAccessor< Vectors3 > &objectPointGroups, const ConstIndexedAccessor< Vectors2 > &imagePointGroups, SharedAnyCamera &optimizedCamera, NonconstIndexedAccessor< HomogenousMatrix4 > *flippedOptimizedCameras_T_world, const unsigned int iterations, const OptimizationStrategy optimizationStrategy=OS_ALL_PARAMETERS_AFTER_ANOTHER, 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 corresponding image points in several 6DOF camera poses.
 
static bool optimizeCameraPoses (const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< HomogenousMatrix4 > &world_T_cameras, const ConstIndexedAccessor< Vectors3 > &objectPointGroups, const ConstIndexedAccessor< Vectors2 > &imagePointGroups, PinholeCamera &optimizedCamera, NonconstIndexedAccessor< HomogenousMatrix4 > *world_T_optimizedCameras, 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)
 Deprecated.
 
static bool optimizeCameraPosesIF (const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< HomogenousMatrix4 > &flippedCameras_T_world, const ConstIndexedAccessor< Vectors3 > &objectPointGroups, const ConstIndexedAccessor< Vectors2 > &imagePointGroups, PinholeCamera &optimizedCamera, NonconstIndexedAccessor< HomogenousMatrix4 > *flippedOptimizedCameras_T_world, 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)
 Deprecated.
 
static bool optimizeCameraObjectPointsPoses (const PinholeCamera &pinholeCamera, const ConstIndexedAccessor< HomogenousMatrix4 > &world_T_cameras, const ConstIndexedAccessor< Vector3 > &objectPoints, const ObjectPointGroupsAccessor &correspondenceGroups, const PinholeCamera::OptimizationStrategy optimizationStrategy, PinholeCamera &optimizedCamera, 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 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.
 
static std::vector< size_tcameraParametersPerOptimizationStage (const AnyCamera &camera, const OptimizationStrategy optimizationStrategy)
 Returns the number of camera parameters which should be optimized during individual optimization stages.
 

Static Protected Member Functions

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 correspondences of ids of 3D object points and 2D image point locations from the individual frames.
 
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 correspondences between pose indices and 2D image points locations within the pose frames.
 
- Static Protected Member Functions inherited from Ocean::Geometry::NonLinearOptimization
template<typename T >
static bool denseOptimization (T &provider, const unsigned int iterations=5u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr, const Matrix *invertedCovariances=nullptr, Scalars *intermediateErrors=nullptr)
 Invokes the optimization of a dense (matrix) optimization problem.
 
template<typename T , Estimator::EstimatorType tEstimator>
static bool denseOptimization (T &provider, const unsigned int iterations=5u, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr, const Matrix *invertedCovariances=nullptr, Scalars *intermediateErrors=nullptr)
 Invokes the optimization of a dense (matrix) optimization problem.
 
template<typename T >
static bool sparseOptimization (T &provider, const unsigned int iterations=5u, const Estimator::EstimatorType estimator=Estimator::ET_SQUARE, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr, const Matrix *invertedCovariances=nullptr, Scalars *intermediateErrors=nullptr)
 Invokes the optimization of a sparse (matrix) optimization problem.
 
template<typename T , Estimator::EstimatorType tEstimator>
static bool sparseOptimization (T &provider, const unsigned int iterations=5u, Scalar lambda=Scalar(0.001), const Scalar lambdaFactor=Scalar(5), Scalar *initialError=nullptr, Scalar *finalError=nullptr, const Matrix *invertedCovariances=nullptr, Scalars *intermediateErrors=nullptr)
 Invokes the optimization of a sparse (matrix) optimization problem.
 
template<typename T >
static bool advancedDenseOptimization (T &advancedDenseProvider, const unsigned int iterations, Scalar lambda, const Scalar lambdaFactor, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
 Invokes the optimization of a dense (matrix) optimization problem using an advanced optimization provider.
 
template<typename T >
static bool advancedSparseOptimization (T &advancedSparseProvider, const unsigned int iterations, Scalar lambda, const Scalar lambdaFactor, Scalar *initialError=nullptr, Scalar *finalError=nullptr, Scalars *intermediateErrors=nullptr)
 Invokes the optimization of a sparse (matrix) optimization problem using an advanced optimization provider.
 
template<Estimator::EstimatorType tEstimator>
static Scalar sqrErrors2robustErrors2 (const Scalars &sqrErrors, const size_t modelParameters, Vector2 *weightedErrors, Vector2 *weightVectors, const SquareMatrix2 *transposedInvertedCovariances)
 Translates the n/2 squared errors that correspond to n elements in the error vector to robust errors.
 
template<Estimator::EstimatorType tEstimator, size_t tDimension>
static Scalar sqrErrors2robustErrors (const Scalars &sqrErrors, const size_t modelParameters, StaticBuffer< Scalar, tDimension > *weightedErrors, StaticBuffer< Scalar, tDimension > *weightVectors, const Matrix *transposedInvertedCovariances)
 Translates the n/i squared errors that correspond to n elements in the error vector to robust errors.
 
template<Estimator::EstimatorType tEstimator>
static Scalar sqrErrors2robustErrors_i (const Scalars &sqrErrors, const size_t modelParameters, const size_t dimension, Scalar *weightedErrors_i, Scalar *weightVectors_i, const Matrix *transposedInvertedCovariances_i)
 Translates the n/i squared errors that correspond to n elements in the error vector to robust errors.
 
static Scalar sqrErrors2robustErrors2 (const Estimator::EstimatorType estimator, const Scalars &sqrErrors, const size_t modelParameters, Vector2 *weightedErrors, Vector2 *weightVectors, const SquareMatrix2 *transposedInvertedCovariances)
 Translates the n/2 squared errors that correspond to n elements in the error vector to robust errors.
 
template<size_t tDimension>
static Scalar sqrErrors2robustErrors (const Estimator::EstimatorType estimator, const Scalars &sqrErrors, const size_t modelParameters, StaticBuffer< Scalar, tDimension > *weightedErrors, StaticBuffer< Scalar, tDimension > *weightVectors, const Matrix *transposedInvertedCovariances)
 Translates the n/i squared errors that correspond to n elements in the error vector to robust errors.
 
static Scalar sqrErrors2robustErrors_i (const Estimator::EstimatorType estimator, const Scalars &sqrErrors, const size_t modelParameters, const size_t dimension, Scalar *weightedErrors_i, Scalar *weightVectors_i, const Matrix *transposedInvertedCovariances_i)
 Translates the n/i squared errors that correspond to n elements in the error vector to robust errors.
 

Detailed Description

This class implements least square or robust optimization algorithms for camera profiles.

Member Enumeration Documentation

◆ OptimizationStrategy

Definition of individual optimization strategies for how the camera parameters can be optimized.

Enumerator
OS_INVALID 

An invalid optimization strategy.

OS_ONLY_FOCAL_LENGTH 

One stage optimization: Only the focal length parameter(s) of the camera profile will be optimized (at once).

OS_UP_TO_PRINCIPAL_POINT_AFTER_ANOTHER 

Two stage optimization: First the focal length parameter(s) will be optimized in a first stage, followed by the principal point.

OS_UP_TO_MAJOR_DISTORTION_AFTER_ANOTHER 

Multi-stage optimization: First the focal length parameter(s) will be optimized in a first stage, followed by the principal point, followed by the major distortion parameters (one after another).

OS_ALL_PARAMETERS_AT_ONCE 

Single stage optimization: All parameters of the camera profile will be optimized at once.

OS_ALL_PARAMETERS_AFTER_ANOTHER 

Multi-stage optimization: First the focal length parameter(s) will be optimized in a first stage, followed by the principal point, followed by all distortion parameters (one after another), this strategy will create the most accurate camera profile.

Member Function Documentation

◆ cameraParametersPerOptimizationStage()

static std::vector< size_t > Ocean::Geometry::NonLinearOptimizationCamera::cameraParametersPerOptimizationStage ( const AnyCamera camera,
const OptimizationStrategy  optimizationStrategy 
)
static

Returns the number of camera parameters which should be optimized during individual optimization stages.

Parameters
cameraThe camera profile for which the number of parameters will be returned, must be valid
optimizationStrategyThe optimization strategy for which the number of parameter will be returned, one for each optimization stage
Returns
The number of parameters for each optimization stage

◆ findInitialFieldOfView() [1/2]

static bool Ocean::Geometry::NonLinearOptimizationCamera::findInitialFieldOfView ( const PinholeCamera pinholeCamera,
const ConstIndexedAccessor< HomogenousMatrix4 > &  world_T_cameras,
const ConstIndexedAccessor< Vector3 > &  objectPoints,
const ObjectPointGroupsAccessor correspondenceGroups,
PinholeCamera optimizedCamera,
NonconstIndexedAccessor< HomogenousMatrix4 > *  world_T_optimizedCameras,
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 
)
static

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.

The number of correspondences may vary between the individual frames (groups).
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.

Parameters
pinholeCameraThe pinhole camera profile for which the better field of view will be determined, must be valid
world_T_camerasThe accessor for the known poses of the individual camera frames
objectPointsThe accessor for the individual 3D object points
correspondenceGroupsThe accessor for the individual groups of correspondences between pose ids and image point location, one group for each object point
optimizedCameraThe resulting camera profile with best matching field of view
world_T_optimizedCamerasOptional accessor for the resulting optimized camera poses matching with the new camera profile
optimizedObjectPointsOptional accessor for the resulting optimized object point locations
lowerFovXThe lower bound of the possible horizontal field of view in radian, with range (0, upperFovX]
upperFovXThe upper bound of the possible horizontal field of view in radian, with range [lowerFovX, PI)
stepsThe number of steps in which the defined angle range is subdivided, with range [4, infinity)
recursiveIterationsThe 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)
onlyFrontObjectPointsTrue, to avoid that the optimized 3D position lies behind any camera
significantResultOptional resulting whether the resulting field of view has an significant impact on the error; True, of so
finalErrorOptional resulting averaged square pixel error for the camera profile with the best matching field of view
workerOptional worker object to distribute the computation
abortOptional abort statement allowing to stop the execution; True, if the execution has to stop
Returns
True, if succeeded and the execution has not been aborted

◆ findInitialFieldOfView() [2/2]

static bool Ocean::Geometry::NonLinearOptimizationCamera::findInitialFieldOfView ( const PinholeCamera pinholeCamera,
const ConstIndexedAccessor< SquareMatrix3 > &  world_R_cameras,
const PoseGroupsAccessor correspondenceGroups,
PinholeCamera optimizedCamera,
NonconstIndexedAccessor< SquareMatrix3 > *  world_R_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 
)
static

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.

The number of correspondences may vary between the individual frames (groups).
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.

Parameters
pinholeCameraThe pinhole camera profile for which the better field of view will be determined, must be valid
world_R_camerasThe accessor for the known orientations of the individual camera frames
correspondenceGroupsThe accessor for the individual groups of point correspondences, one group for each orientation
optimizedCameraThe resulting camera profile with best matching field of view
world_R_optimizedOrientationsOptional accessor for the optimized camera orientations matching with the new camera profile
lowerFovXThe lower bound of the possible horizontal field of view in radian, with range (0, upperFovX]
upperFovXThe upper bound of the possible horizontal field of view in radian, with range [lowerFovX, PI)
stepsThe number of steps in which the defined angle range is subdivided, with range [4, infinity)
recursiveIterationsThe 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)
onlyFrontObjectPointsTrue, to avoid that the optimized 3D position lies behind any camera
significantResultOptional resulting whether the resulting field of view has an significant impact on the error; True, of so
finalErrorOptional resulting averaged square pixel error for the camera profile with the best matching field of view
workerOptional worker object to distribute the computation
abortOptional abort statement allowing to stop the execution; True, if the execution has to stop
Returns
True, if succeeded and the execution has not been aborted

◆ findInitialFieldOfViewSubset() [1/2]

static void Ocean::Geometry::NonLinearOptimizationCamera::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 
)
staticprotected

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.

The number of correspondences may vary between the individual frames (groups).
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.

Parameters
pinholeCameraThe pinhole camera profile for which the better field of view will be determined, must be valid
posesThe accessor for the known poses of the individual camera frames
objectPointsThe accessor for the individual 3D object points
correspondenceGroupsThe accessor for the individual groups of correspondences between pose ids and image point location, one group for each object point
optimizedCameraThe resulting camera profile with best matching field of view
optimizedPosesOptional accessor for the resulting optimized camera poses matching with the new camera profile
optimizedObjectPointsOptional accessor for the resulting optimized object point locations
lowerFovXThe lower bound of the possible horizontal field of view in radian, with range (0, upperFovX]
upperFovXThe upper bound of the possible horizontal field of view in radian, with range [lowerFovX, PI)
overallStepsThe overall number of steps in which the defined angle range is subdivided, with range [4, infinity)
onlyFrontObjectPointsTrue, to avoid that the optimized 3D position lies behind any camera
bestErrorResulting averaged square pixel error for the camera profile with the best matching field of view
allErrorsOptional 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)
lockThe lock object, must be defined if this function is executed in parallel on individual threads, nullptr otherwise
abortOptional abort statement allowing to stop the execution; True, if the execution has to stop
firstStepThe first step to be handled, with range [0, overallSteps)
stepsThe number of steps which will be handled (from the entire number of overall steps), with range [1, overallSteps]

◆ findInitialFieldOfViewSubset() [2/2]

static void Ocean::Geometry::NonLinearOptimizationCamera::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 
)
staticprotected

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.

The number of correspondences may vary between the individual frames (groups).
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.

Parameters
pinholeCameraThe pinhole camera profile for which the better field of view will be determined, must be valid
orientationsThe accessor for the known orientations of the individual camera frames
correspondenceGroupsThe accessor for the individual groups of point correspondences, one group for each orientation
optimizedCameraThe resulting camera profile with best matching field of view
optimizedOrientationsOptional accessor for the optimized camera orientations matching with the new camera profile
lowerFovXThe lower bound of the possible horizontal field of view in radian, with range (0, upperFovX]
upperFovXThe upper bound of the possible horizontal field of view in radian, with range [lowerFovX, PI)
overallStepsThe overall number of steps in which the defined angle range is subdivided, with range [4, infinity)
onlyFrontObjectPointsTrue, to avoid that the optimized 3D position lies behind any camera
bestErrorResulting averaged square pixel error for the camera profile with the best matching field of view
allErrorsOptional 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)
lockLock object, must be defined if this function is executed in parallel on individual threads, nullptr otherwise
abortOptional abort statement allowing to stop the execution; True, if the execution has to stop
firstStepThe first step to be handled, with range [0, overallSteps)
stepsThe number of steps which will be handled (from the entire number of overall steps), with range [1, overallSteps]

◆ optimizeCamera()

static bool Ocean::Geometry::NonLinearOptimizationCamera::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 
)
static

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.

Which parameter of the camera profile will be optimized depends on the specified optimization strategy.

Parameters
pinholeCameraThe pinhole camera profile with initial distortion parameters to optimize
normalizedObjectPointsThe accessor for the projected 3D object points (the normalized image/object points)
imagePointsimagePoints 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
optimizationStrategyThe optimization strategy to be used
optimizedCameraResulting optimized camera object holding optimized intrinsic and distortion parameters
iterationsNumber of iterations to be applied at most, if no convergence can be reached
estimatorRobust error estimator to be used
lambdaInitial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
lambdaFactorLevenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
initialErrorOptional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
finalErrorOptional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
Returns
True, if succeeded

◆ optimizeCameraObjectPointsPoses()

static bool Ocean::Geometry::NonLinearOptimizationCamera::optimizeCameraObjectPointsPoses ( const PinholeCamera pinholeCamera,
const ConstIndexedAccessor< HomogenousMatrix4 > &  world_T_cameras,
const ConstIndexedAccessor< Vector3 > &  objectPoints,
const ObjectPointGroupsAccessor correspondenceGroups,
const PinholeCamera::OptimizationStrategy  optimizationStrategy,
PinholeCamera optimizedCamera,
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 
)
static

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.

This function also optimized the camera poses and the locations of the 3D object point while the camera profile is optimized.
The number of 2D/3D point correspondences may vary between the individual frames (groups).
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.

Parameters
pinholeCameraThe pinhole camera profile to optimized
world_T_camerasThe accessor for the known poses of the individual camera frames
objectPointsThe accessor for the known 3D object points locations
correspondenceGroupsThe accessor for the individual groups of correspondences between pose indices and image points, one group for each object point
optimizationStrategyThe optimization strategy for the camera profile
optimizedCameraThe resulting optimized camera profile
world_T_optimizedCamerasOptional accessor for the resulting optimized camera poses, matching with the new camera profile
optimizedObjectPointsOptional accessor for the resulting optimized 3D object point locations, matching with the new camera profile
iterationsNumber of iterations to be applied at most, if no convergence can be reached
estimatorRobust error estimator to be used
lambdaInitial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
lambdaFactorLevenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
onlyFrontObjectPointsTrue, to avoid that the optimized 3D position lies behind any camera
initialErrorOptional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
finalErrorOptional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
intermediateErrorsOptional resulting intermediate averaged pixel errors for the individual optimization steps, in relation to the defined estimator
Returns
True, if succeeded

◆ optimizeCameraOrientations()

static bool Ocean::Geometry::NonLinearOptimizationCamera::optimizeCameraOrientations ( const PinholeCamera pinholeCamera,
const ConstIndexedAccessor< SquareMatrix3 > &  world_R_cameras,
const PoseGroupsAccessor correspondenceGroups,
const PinholeCamera::OptimizationStrategy  optimizationStrategy,
PinholeCamera optimizedCamera,
NonconstIndexedAccessor< SquareMatrix3 > *  world_R_optimizedCameras,
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 
)
static

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.

The number of points correspondences may vary between the individual frames (groups).
Each group may address individual object points.

Parameters
pinholeCameraThe pinhole camera profile to optimized
world_R_camerasThe accessor for the known orientations of the individual camera frames
correspondenceGroupsThe accessor for the individual groups of point correspondences, one group for each orientation
optimizationStrategyThe optimization strategy
optimizedCameraThe resulting camera profile with ideal field of view
world_R_optimizedCamerasOptional accessor for the optimized camera orientations matching with the new camera profile
iterationsNumber of iterations to be applied at most, if no convergence can be reached
estimatorRobust error estimator to be used
lambdaInitial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
lambdaFactorLevenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
onlyFrontObjectPointsTrue, to avoid that the optimized 3D position lies behind any camera
initialErrorOptional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
finalErrorOptional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
intermediateErrorsOptional resulting intermediate averaged pixel errors for the individual optimization steps, in relation to the defined estimator
Returns
True, if succeeded

◆ optimizeCameraPoses() [1/2]

static bool Ocean::Geometry::NonLinearOptimizationCamera::optimizeCameraPoses ( const AnyCamera camera,
const ConstIndexedAccessor< HomogenousMatrix4 > &  world_T_cameras,
const ConstIndexedAccessor< Vectors3 > &  objectPointGroups,
const ConstIndexedAccessor< Vectors2 > &  imagePointGroups,
SharedAnyCamera optimizedCamera,
NonconstIndexedAccessor< HomogenousMatrix4 > *  world_T_optimizedCameras,
const unsigned int  iterations,
const OptimizationStrategy  optimizationStrategy = OS_ALL_PARAMETERS_AFTER_ANOTHER,
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 
)
static

Minimizes the projection error between the projections of static 3D object points and their corresponding image points in several 6DOF camera poses.

The camera profile as well as the camera poses are optimized concurrently.

Parameters
cameraThe camera profile to optimize, must be valid
world_T_camerasThe individual camera poses, one pose for each pair of groups of object points and image points
objectPointGroupsThe accessor for the individual groups of 3D object points, one group for each camera pose with at least one object point
imagePointGroupsThe accessor for the individual groups of 2D image points, one group for each camera pose and one image point for each corresponding object point
optimizedCameraThe resulting optimized camera profile
world_T_optimizedCamerasOptional accessor for the resulting optimized camera poses, matching with the new camera profile
iterationsThe maximal number of iterations to be applied per optimization stage (depending on the optimizationStrategy), if no convergence can be reached
optimizationStrategyThe optimization strategy to be used
estimatorRobust error estimator to be used
lambdaInitial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
lambdaFactorLevenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
onlyFrontObjectPointsTrue, to avoid that the optimized 3D position lies behind any camera
initialErrorOptional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
finalErrorOptional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
intermediateErrorsOptional resulting intermediate averaged pixel errors for the individual optimization steps, in relation to the defined estimator
Returns
True, if succeeded
See also
optimizeCameraPoseIF().

◆ optimizeCameraPoses() [2/2]

static bool Ocean::Geometry::NonLinearOptimizationCamera::optimizeCameraPoses ( const PinholeCamera pinholeCamera,
const ConstIndexedAccessor< HomogenousMatrix4 > &  world_T_cameras,
const ConstIndexedAccessor< Vectors3 > &  objectPointGroups,
const ConstIndexedAccessor< Vectors2 > &  imagePointGroups,
PinholeCamera optimizedCamera,
NonconstIndexedAccessor< HomogenousMatrix4 > *  world_T_optimizedCameras,
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 
)
static

Deprecated.

Minimizes the projection error between the projections of static 3D object points and their corresponding image points in several 6DOF camera poses. The camera profile as well as the camera poses are optimized concurrently.

Parameters
pinholeCameraThe pinhole camera holding intrinsic and distortion parameters to minimize the projection error for.
world_T_camerasThe individual camera poses, one pose for each pair of groups of object points and image points
objectPointGroupsThe accessor for the individual groups of 3D object points, one group for each camera pose with at least one object point
imagePointGroupsThe accessor for the individual groups of 2D image points, one group for each camera pose and one image point for each corresponding object point
optimizedCameraThe resulting optimized camera profile
world_T_optimizedCamerasOptional accessor for the resulting optimized camera poses, matching with the new camera profile
iterationsNumber of iterations to be applied at most, if no convergence can be reached
estimatorRobust error estimator to be used
lambdaInitial Levenberg-Marquardt damping value which may be changed after each iteration using the damping factor, with range [0, infinity)
lambdaFactorLevenberg-Marquardt damping factor to be applied to the damping value, with range [1, infinity)
onlyFrontObjectPointsTrue, to avoid that the optimized 3D position lies behind any camera
initialErrorOptional resulting averaged pixel error for the given initial parameters, in relation to the defined estimator
finalErrorOptional resulting averaged pixel error for the final optimized parameters, in relation to the defined estimator
intermediateErrorsOptional resulting intermediate averaged pixel errors for the individual optimization steps, in relation to the defined estimator
Returns
True, if succeeded
See also
optimizeCameraPoseIF().

◆ optimizeCameraPosesIF() [1/2]

static bool Ocean::Geometry::NonLinearOptimizationCamera::optimizeCameraPosesIF ( const AnyCamera camera,
const ConstIndexedAccessor< HomogenousMatrix4 > &  flippedCameras_T_world,
const ConstIndexedAccessor< Vectors3 > &  objectPointGroups,
const ConstIndexedAccessor< Vectors2 > &  imagePointGroups,
SharedAnyCamera optimizedCamera,
NonconstIndexedAccessor< HomogenousMatrix4 > *  flippedOptimizedCameras_T_world,
const unsigned int  iterations,
const OptimizationStrategy  optimizationStrategy = OS_ALL_PARAMETERS_AFTER_ANOTHER,
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 
)
static

Minimizes the projection error between the projections of static 3D object points and their corresponding image points in several 6DOF camera poses.

The given poses must be inverted and flipped around the new x axis by 180 degree.

See also
optimizeCameraPose().

◆ optimizeCameraPosesIF() [2/2]

static bool Ocean::Geometry::NonLinearOptimizationCamera::optimizeCameraPosesIF ( const PinholeCamera pinholeCamera,
const ConstIndexedAccessor< HomogenousMatrix4 > &  flippedCameras_T_world,
const ConstIndexedAccessor< Vectors3 > &  objectPointGroups,
const ConstIndexedAccessor< Vectors2 > &  imagePointGroups,
PinholeCamera optimizedCamera,
NonconstIndexedAccessor< HomogenousMatrix4 > *  flippedOptimizedCameras_T_world,
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 
)
static

Deprecated.

Minimizes the projection error between the projections of static 3D object points and their corresponding image points in several 6DOF camera poses. The given poses must be inverted and flipped around the new x axis by 180 degree.

See also
optimizeCameraPose().

The documentation for this class was generated from the following file: