8 #ifndef META_OCEAN_GEOMETRY_NON_LINEAR_OPTIMIZATION_PLANE_H
9 #define META_OCEAN_GEOMETRY_NON_LINEAR_OPTIMIZATION_PLANE_H
52 class OnePoseOnePlaneData;
62 class GeneralizedPosesPlaneData;
104 static inline bool optimizeOnePoseOnePlane(
const PinholeCamera& pinholeCamera,
const HomogenousMatrix4& world_T_cameraFirst,
const HomogenousMatrix4& world_T_cameraSecond,
const Plane3& plane,
const ConstIndexedAccessor<Vector2>& imagePointsFirst,
const ConstIndexedAccessor<Vector2>& imagePointsSecond,
const bool distortImagePoints,
HomogenousMatrix4& world_T_optimizedCameraSecond,
Plane3& optimizedPlane,
const unsigned int iterations = 20u,
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);
113 static bool optimizeOnePoseOnePlaneIF(
const PinholeCamera& pinholeCamera,
const HomogenousMatrix4& flippedCameraFirst_T_world,
const HomogenousMatrix4& flippedCameraSecond_T_world,
const Plane3& plane,
const ConstIndexedAccessor<Vector2>& imagePointsFirst,
const ConstIndexedAccessor<Vector2>& imagePointsSecond,
const bool distortImagePoints,
HomogenousMatrix4& optimizedFlippedCameraSecond_T_world,
Plane3& optimizedPlane,
const unsigned int iterations = 20u,
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);
138 static inline bool optimizePosesPlane(
const PinholeCamera& pinholeCamera,
const HomogenousMatrix4& world_T_camera,
const Vectors2& imagePointsFirst,
const HomogenousMatrices4& world_T_cameras,
const Plane3& plane,
const ImagePointGroups& imagePointGroups,
const bool distortImagePoints,
HomogenousMatrices4& world_T_optimizedCameras,
Plane3& optimizedPlane,
const unsigned int iterations = 20u,
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);
147 static bool optimizePosesPlaneIF(
const PinholeCamera& pinholeCamera,
const HomogenousMatrix4& flippedCamera_T_world,
const Vectors2& imagePointsFirst,
const HomogenousMatrices4& flippedCameras_T_world,
const Plane3& plane,
const ImagePointGroups& imagePointGroups,
const bool distortImagePoints,
HomogenousMatrices4& optimizedFlippedCameras_T_world,
Plane3& optimizedPlane,
const unsigned int iterations = 20u,
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);
171 static inline bool optimizePosesPlane(
const PinholeCamera& pinholeCamera,
const HomogenousMatrix4& world_T_camera,
const HomogenousMatrices4& world_T_cameras,
const ImagePointsPairs& imagePointPairGroups,
const Plane3& plane,
const bool distortImagePoints,
HomogenousMatrices4& world_T_optimizedCameras,
Plane3& optimizedPlane,
const unsigned int iterations = 20u,
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);
180 static bool optimizePosesPlaneIF(
const PinholeCamera& pinholeCamera,
const HomogenousMatrix4& flippedCamera_T_world,
const HomogenousMatrices4& flippedCameras_T_world,
const ImagePointsPairs& imagePointPairGroups,
const Plane3& plane,
const bool distortImagePoints,
HomogenousMatrices4& optimizedFlippedCameras_T_world,
Plane3& optimizedPlane,
const unsigned int iterations = 20u,
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);
183 inline bool NonLinearOptimizationPlane::optimizeOnePoseOnePlane(
const PinholeCamera& pinholeCamera,
const HomogenousMatrix4& world_T_cameraFirst,
const HomogenousMatrix4& world_T_cameraSecond,
const Plane3& plane,
const ConstIndexedAccessor<Vector2>& imagePointsFirst,
const ConstIndexedAccessor<Vector2>& imagePointsSecond,
const bool distortImagePoints,
HomogenousMatrix4& world_T_optimizedCameraSecond,
Plane3& optimizedPlane,
const unsigned int iterations,
const Estimator::EstimatorType estimator,
Scalar lambda,
const Scalar lambdaFactor,
const bool onlyFrontObjectPoints,
Scalar* initialError,
Scalar* finalError)
185 ocean_assert(pinholeCamera.
isValid());
186 ocean_assert(world_T_cameraFirst.
isValid() && world_T_cameraSecond.
isValid());
187 ocean_assert(imagePointsFirst.
size() == imagePointsSecond.
size());
192 if (!
optimizeOnePoseOnePlaneIF(pinholeCamera, flippedCameraFirst_T_world, flippedCameraSecond_T_world, plane, imagePointsFirst, imagePointsSecond, distortImagePoints, world_T_optimizedCameraSecond, optimizedPlane, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialError, finalError))
201 inline bool NonLinearOptimizationPlane::optimizePosesPlane(
const PinholeCamera& pinholeCamera,
const HomogenousMatrix4& world_T_cameraFirst,
const Vectors2& imagePointsFirst,
const HomogenousMatrices4& world_T_cameras,
const Plane3& plane,
const ImagePointGroups& imagePointGroups,
const bool distortImagePoints,
HomogenousMatrices4& world_T_optimizedCameras,
Plane3& optimizedPlane,
const unsigned int iterations,
const Estimator::EstimatorType estimator,
Scalar lambda,
const Scalar lambdaFactor,
const bool onlyFrontObjectPoints,
Scalar* initialError,
Scalar* finalError)
206 if (!
optimizePosesPlaneIF(pinholeCamera, flippedCameraFirst_T_world, imagePointsFirst, flippedCameras_T_world, plane, imagePointGroups, distortImagePoints, world_T_optimizedCameras, optimizedPlane, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialError, finalError))
215 inline bool NonLinearOptimizationPlane::optimizePosesPlane(
const PinholeCamera& pinholeCamera,
const HomogenousMatrix4& firstPose,
const HomogenousMatrices4& poses,
const ImagePointsPairs& imagePointPairGroups,
const Plane3& plane,
const bool distortImagePoints,
HomogenousMatrices4& world_T_optimizedCameras,
Plane3& optimizedPlane,
const unsigned int iterations,
const Estimator::EstimatorType estimator,
Scalar lambda,
const Scalar lambdaFactor,
const bool onlyFrontObjectPoints,
Scalar* initialError,
Scalar* finalError)
219 if (!
optimizePosesPlaneIF(pinholeCamera,
PinholeCamera::standard2InvertedFlipped(firstPose), posesIF, imagePointPairGroups, plane, distortImagePoints, world_T_optimizedCameras, optimizedPlane, iterations, estimator, lambda, lambdaFactor, onlyFrontObjectPoints, initialError, finalError))
virtual size_t size() const =0
Returns the number of accessible elements of this accessor object.
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
EstimatorType
Definition of individual robust estimator types.
Definition: Estimator.h:34
@ ET_SQUARE
The standard square error estimator (L2).
Definition: Estimator.h:52
This class implements the basic functions for least square or robust optimization algorithms for non ...
Definition: NonLinearOptimization.h:34
This class implements least square or robust optimization algorithms for 3D planes.
Definition: NonLinearOptimizationPlane.h:29
static bool optimizeOnePoseOnePlaneIF(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &flippedCameraFirst_T_world, const HomogenousMatrix4 &flippedCameraSecond_T_world, const Plane3 &plane, const ConstIndexedAccessor< Vector2 > &imagePointsFirst, const ConstIndexedAccessor< Vector2 > &imagePointsSecond, const bool distortImagePoints, HomogenousMatrix4 &optimizedFlippedCameraSecond_T_world, Plane3 &optimizedPlane, const unsigned int iterations=20u, 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)
Optimizes the orientation of a plane in 3D spaces and the pose of one camera pose.
static bool optimizePosesPlaneIF(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &flippedCamera_T_world, const HomogenousMatrices4 &flippedCameras_T_world, const ImagePointsPairs &imagePointPairGroups, const Plane3 &plane, const bool distortImagePoints, HomogenousMatrices4 &optimizedFlippedCameras_T_world, Plane3 &optimizedPlane, const unsigned int iterations=20u, 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)
Optimizes the orientation of a plane in 3D spaces and several (inverted and flipped) camera poses con...
std::pair< Vectors2, Vectors2 > ImagePointsPair
Definition of a pair holding to sets of corresponding image points.
Definition: NonLinearOptimizationPlane.h:35
static bool optimizeOnePoseOnePlane(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &world_T_cameraFirst, const HomogenousMatrix4 &world_T_cameraSecond, const Plane3 &plane, const ConstIndexedAccessor< Vector2 > &imagePointsFirst, const ConstIndexedAccessor< Vector2 > &imagePointsSecond, const bool distortImagePoints, HomogenousMatrix4 &world_T_optimizedCameraSecond, Plane3 &optimizedPlane, const unsigned int iterations=20u, 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)
Optimizes the orientation of a plane in 3D spaces and the pose of one camera pose.
Definition: NonLinearOptimizationPlane.h:183
std::vector< ImagePointsPair > ImagePointsPairs
Definition of a vector holding pairs of corresponding image points.
Definition: NonLinearOptimizationPlane.h:40
static bool optimizePosesPlaneIF(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &flippedCamera_T_world, const Vectors2 &imagePointsFirst, const HomogenousMatrices4 &flippedCameras_T_world, const Plane3 &plane, const ImagePointGroups &imagePointGroups, const bool distortImagePoints, HomogenousMatrices4 &optimizedFlippedCameras_T_world, Plane3 &optimizedPlane, const unsigned int iterations=20u, 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)
Optimizes the orientation of a plane in 3D spaces and several (inverted and flipped) camera poses con...
static bool optimizePlane(const Plane3 &plane, const ConstIndexedAccessor< Vector3 > &pointAccessor, Plane3 &optimizedPlane, 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 a 3D plane by reducing the distance between 3D object points and their projected plane poin...
static bool optimizePosesPlane(const PinholeCamera &pinholeCamera, const HomogenousMatrix4 &world_T_camera, const Vectors2 &imagePointsFirst, const HomogenousMatrices4 &world_T_cameras, const Plane3 &plane, const ImagePointGroups &imagePointGroups, const bool distortImagePoints, HomogenousMatrices4 &world_T_optimizedCameras, Plane3 &optimizedPlane, const unsigned int iterations=20u, 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)
Optimizes the orientation of a plane in 3D spaces and several camera poses concurrently.
Definition: NonLinearOptimizationPlane.h:201
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition: HomogenousMatrix4.h:1806
bool isValid() const
Returns whether this camera is valid.
Definition: PinholeCamera.h:1572
std::vector< ImagePoints > ImagePointGroups
Definition of a vector holding image points, so we have groups of image points.
Definition: geometry/Geometry.h:141
float Scalar
Definition of a scalar type.
Definition: Math.h:128
std::vector< HomogenousMatrix4 > HomogenousMatrices4
Definition of a vector holding HomogenousMatrix4 objects.
Definition: HomogenousMatrix4.h:73
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition: Vector2.h:64
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15