8#ifndef META_OCEAN_TRACKING_POSE_PROJECTION_H
9#define META_OCEAN_TRACKING_POSE_PROJECTION_H
71 inline size_t size()
const;
83 template <Geometry::Estimator::EstimatorType tEstimator>
96 explicit inline operator bool()
const;
147 inline unsigned int index()
const;
193 inline unsigned int width()
const;
200 inline unsigned int height()
const;
218 inline size_t size()
const;
245 template <Geometry::Estimator::EstimatorType tEstimator>
262 template <Geometry::Estimator::EstimatorType tEstimator>
275 explicit inline operator bool()
const;
290 template <Geometry::Estimator::EstimatorType tEstimator>
330inline PoseProjection::operator bool()
const
371inline PoseProjectionSet::operator bool()
const
398template <Geometry::Estimator::EstimatorType tEstimator>
406 const size_t points = min(
size(), numberImagePoints);
407 const size_t validPoints = min(validImagePoints, points);
412template <Geometry::Estimator::EstimatorType tEstimator>
426 worker->
executeFunction(
Worker::Function::create(*
this, &
PoseProjectionSet::findPoseWithMinimalErrorSubset<tEstimator>, imagePoints, numberImagePoints, validImagePoints, errorDetermination, errorObjects.data(), 0u, 0u), 0u,
size(), 5u, 6u);
433 std::sort(errorObjects.begin(), errorObjects.end());
435 if (resultingError !=
nullptr)
437 *resultingError = errorObjects.front().error();
444template <Geometry::Estimator::EstimatorType tEstimator>
449 if (
isEmpty() || numberPoses == 0)
458 worker->
executeFunction(
Worker::Function::create(*
this, &
PoseProjectionSet::findPoseWithMinimalErrorSubset<tEstimator>, imagePoints, numberImagePoints, validImagePoints, errorDetermination, errorObjects.data(), 0u, 0u), 0u, (
unsigned int)
size(), 5u, 6u);
468 std::sort(errorObjects.begin(), errorObjects.end());
470 const size_t results = min(numberPoses, errorObjects.size());
472 for (
size_t n = 0; n < results; ++n)
478 resultingErrors[n] = errorObjects[n].error();
482 return (
unsigned int)(results);
485template <Geometry::Estimator::EstimatorType tEstimator>
488 ocean_assert(imagePoints);
489 ocean_assert(errorObjects);
491 ocean_assert(firstProjection + numberProjections <=
poseProjections_.size());
493 for (
unsigned int n = firstProjection; n < firstProjection + numberProjections; ++n)
495 const Scalar errorValue =
poseProjections_[n].minimalAverageSquareError<tEstimator>(imagePoints, numberImagePoints, validImagePoints, errorDetermination);
static Caller< void > create(CT &object, typename MemberFunctionPointerMaker< CT, void, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass, NullClass >::Type function)
ErrorDetermination
Definition of different error determination stages.
Definition Error.h:41
static Scalar averagedRobustErrorInPointCloud(const Vector2 *imagePoints, const size_t numberImagePoints, const size_t validImagePoints, const Vector2 *candidatePoints, const size_t numberCandidatePoints, const ErrorDetermination errorDetermination, IndexPairs32 *correspondences=nullptr)
Determines the unique robust minimal average square error between two 2D points clouds.
Definition Error.h:1061
static constexpr Scalar maxValue()
This class implements a pose projection.
Definition PoseProjection.h:38
PoseProjection(const HomogenousMatrix4 &world_T_camera, const AnyCamera &camera, const Vector3 *objectPoints, const size_t number)
Creates a new pose projection object by a given pose and object points.
Scalar minimalAverageSquareError(const Vector2 *imagePoints, const size_t numberImagePoints, const size_t validImagePoints, const Geometry::Error::ErrorDetermination errorDetermination)
Returns the robust minimal average square error between this pose projection and a given 2D point clo...
Definition PoseProjection.h:399
PoseProjection()=default
Creates an empty pose projection object.
size_t size() const
Returns the number of stored pose points.
Definition PoseProjection.h:320
HomogenousMatrix4 world_T_camera_
Pose of this projection.
Definition PoseProjection.h:110
static const Vector3 & objectPoint2objectPoint(const Vector3 &element)
Converts an element to an object point.
Definition PoseProjection.h:305
Vectors2 imagePoints_
Projection object points for this pose.
Definition PoseProjection.h:113
bool isEmpty() const
Returns whether this pose projection holds no points.
Definition PoseProjection.h:325
const Vectors2 & imagePoints() const
Returns the image points (the projected object points) of this pose projection.
Definition PoseProjection.h:315
const HomogenousMatrix4 & world_T_camera() const
Returns the pose of this projection.
Definition PoseProjection.h:310
This class implements a error object.
Definition PoseProjection.h:133
bool operator<(const ErrorObject &object) const
Returns whether the left object has a lesser error value than the right one.
Definition PoseProjection.h:393
unsigned int objectIndex
Object index.
Definition PoseProjection.h:165
Scalar error() const
Returns the error of this object.
Definition PoseProjection.h:388
Scalar objectError
Object error.
Definition PoseProjection.h:168
ErrorObject(const unsigned int index, const Scalar error)
Creates a new error object.
Definition PoseProjection.h:376
unsigned int index() const
Returns the index of this object.
Definition PoseProjection.h:383
unsigned int findPosesWithMinimalError(const Vector2 *imagePoints, const size_t numberImagePoints, const size_t validImagePoints, const Geometry::Error::ErrorDetermination errorDetermination, const size_t numberPoses, HomogenousMatrix4 *poses, Scalar *resultingErrors=nullptr, Worker *worker=nullptr)
Returns the poses with the minimal distance error.
Definition PoseProjection.h:445
unsigned int cameraWidth_
Width of the camera in pixel used for all pose projections.
Definition PoseProjection.h:299
PoseProjectionSet()=default
Creates an empty set of pose projections.
std::vector< PoseProjection > PoseProjections
Definition of a vector holding pose projections.
Definition PoseProjection.h:127
const PoseProjections & poseProjections() const
Returns the registered pose projections.
Definition PoseProjection.h:356
~PoseProjectionSet()
Destructs a set of pose projections.
unsigned int cameraHeight_
Height of the camera in pixel used for all pose projections.
Definition PoseProjection.h:302
std::vector< ErrorObject > ErrorObjects
Definition of a vector holding error objects.
Definition PoseProjection.h:174
bool isEmpty() const
Returns whether this set holds no pose projections.
Definition PoseProjection.h:366
void setDimension(const unsigned int width, const unsigned int height)
Sets the dimension of the camera used for all pose projections.
Definition PoseProjection.h:345
void findPoseWithMinimalErrorSubset(const Vector2 *imagePoints, const size_t numberImagePoints, const size_t validImagePoints, const Geometry::Error::ErrorDetermination errorDetermination, ErrorObject *errorObjects, const unsigned int firstProjection, const unsigned int numberProjections)
Returns the pose with the minimal distance error for a subset of the pose projections.
Definition PoseProjection.h:486
HomogenousMatrix4 findPoseWithMinimalError(const Vector2 *imagePoints, const size_t numberImagePoints, const size_t validImagePoints, const Geometry::Error::ErrorDetermination errorDetermination, Scalar *resultingError=nullptr, Worker *worker=nullptr)
Returns the pose with the minimal distance error.
Definition PoseProjection.h:413
void clear()
Clears the projection set.
void addPoseProjection(const PoseProjection &poseProjection)
Adds a new pose projection.
Definition PoseProjection.h:351
unsigned int width() const
Returns the width of the camera in pixel used for all projections.
Definition PoseProjection.h:335
PoseProjections poseProjections_
All registered pose projections.
Definition PoseProjection.h:296
size_t size() const
Returns the number of registered pose projections.
Definition PoseProjection.h:361
unsigned int height() const
Returns the height of the camera in pixel used for all projections.
Definition PoseProjection.h:340
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
bool executeFunction(const Function &function, const unsigned int first, const unsigned int size, const unsigned int firstIndex=(unsigned int)(-1), const unsigned int sizeIndex=(unsigned int)(-1), const unsigned int minimalIterations=1u, const unsigned int threadIndex=(unsigned int)(-1))
Executes a callback function separable by two function parameters.
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition Vector2.h:64
HomogenousMatrixT4< Scalar > HomogenousMatrix4
Definition of the HomogenousMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag eit...
Definition HomogenousMatrix4.h:44
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition Vector2.h:28
AnyCameraT< Scalar > AnyCamera
Definition of an AnyCamera object with Scalar precision.
Definition AnyCamera.h:31
VectorT3< Scalar > Vector3
Definition of a 3D vector.
Definition Vector3.h:29
float Scalar
Definition of a scalar type.
Definition Math.h:129
Namespace of the Tracker library.
The namespace covering the entire Ocean framework.
Definition Accessor.h:15