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>
90 inline bool isEmpty()
const;
96 explicit inline operator bool()
const;
147 inline unsigned int index()
const;
153 inline Scalar error()
const;
160 inline bool operator<(
const ErrorObject&
object)
const;
193 inline unsigned int width()
const;
200 inline unsigned int height()
const;
206 inline void addPoseProjection(
const PoseProjection& poseProjection);
218 inline size_t size()
const;
226 inline void setDimension(
const unsigned int width,
const unsigned int height);
245 template <Geometry::Estimator::EstimatorType tEstimator>
262 template <Geometry::Estimator::EstimatorType tEstimator>
269 inline bool isEmpty()
const;
275 explicit inline operator bool()
const;
290 template <Geometry::Estimator::EstimatorType tEstimator>
299 unsigned int cameraWidth_ = 0u;
302 unsigned int cameraHeight_ = 0u;
330inline PoseProjection::operator bool()
const
332 return !imagePoints_.empty();
371inline PoseProjectionSet::operator bool()
const
373 return !poseProjections_.empty();
398template <Geometry::Estimator::EstimatorType tEstimator>
406 const size_t points = min(
size(), numberImagePoints);
407 const size_t validPoints = min(validImagePoints, points);
409 return Geometry::Error::averagedRobustErrorInPointCloud<tEstimator>(imagePoints, points, validPoints, imagePoints_.data(),
size(), errorDetermination);
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);
430 findPoseWithMinimalErrorSubset<tEstimator>(imagePoints, numberImagePoints, validImagePoints, errorDetermination, errorObjects.data(), 0u, (
unsigned int)(
size()));
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);
462 findPoseWithMinimalErrorSubset<tEstimator>(imagePoints, numberImagePoints, validImagePoints, errorDetermination, errorObjects.data(), 0u, (
unsigned int)
size());
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);
This class implements the abstract base class for all AnyCamera objects.
Definition AnyCamera.h:131
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)
Creates a new caller container for a member function with no function parameter.
Definition Caller.h:3024
ErrorDetermination
Definition of different error determination stages.
Definition Error.h:41
static constexpr T maxValue()
Returns the max scalar value.
Definition Numeric.h:3253
This class implements a pose projection.
Definition PoseProjection.h:38
Scalar minimalAverageSquareError(const Geometry::ImagePoint *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.
PoseProjection(const HomogenousMatrix4 &world_T_camera, const AnyCamera &camera, const Geometry::ObjectPoint *objectPoints, const size_t number)
Creates a new pose projection object by a given pose and object points.
const Geometry::ImagePoints & imagePoints() const
Returns the image points (the projected object points) of this pose projection.
Definition PoseProjection.h:315
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
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
static const Vector3 & objectPoint2objectPoint(const Geometry::ObjectPoint &element)
Converts an element to an object point.
Definition PoseProjection.h:305
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
This class implements a set of pose projections.
Definition PoseProjection.h:121
HomogenousMatrix4 findPoseWithMinimalError(const Geometry::ImagePoint *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
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
unsigned int findPosesWithMinimalError(const Geometry::ImagePoint *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
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 Geometry::ImagePoint *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
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< ImagePoint > ImagePoints
Definition of a vector holding 2D image points.
Definition geometry/Geometry.h:123
std::vector< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition Vector2.h:64
float Scalar
Definition of a scalar type.
Definition Math.h:129
HomogenousMatrixT4< Scalar > HomogenousMatrix4
Definition of the HomogenousMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag eit...
Definition HomogenousMatrix4.h:44
The namespace covering the entire Ocean framework.
Definition Accessor.h:15