8 #ifndef META_OCEAN_TRACKING_POSE_PROJECTION_H
9 #define META_OCEAN_TRACKING_POSE_PROJECTION_H
78 inline size_t size()
const;
90 template <Geometry::Estimator::EstimatorType tEstimator>
97 inline bool isEmpty()
const;
103 explicit inline operator bool()
const;
157 inline unsigned int index()
const;
163 inline Scalar error()
const;
170 inline bool operator<(
const ErrorObject&
object)
const;
203 inline unsigned int width()
const;
210 inline unsigned int height()
const;
216 inline void addPoseProjection(
const PoseProjection& poseProjection);
228 inline size_t size()
const;
236 inline void setDimension(
const unsigned int width,
const unsigned int height);
255 template <Geometry::Estimator::EstimatorType tEstimator>
272 template <Geometry::Estimator::EstimatorType tEstimator>
279 inline bool isEmpty()
const;
285 explicit inline operator bool()
const;
300 template <Geometry::Estimator::EstimatorType tEstimator>
345 inline PoseProjection::operator bool()
const
347 return !poseImagePoints.empty();
386 inline PoseProjectionSet::operator bool()
const
388 return !projectionSetPoseProjections.empty();
413 template <Geometry::Estimator::EstimatorType tEstimator>
419 const size_t points = min(
size(), numberImagePoints);
420 const size_t validPoints = min(validImagePoints, points);
422 return Geometry::Error::averagedRobustErrorInPointCloud<tEstimator>(imagePoints, points, validPoints, poseImagePoints.
data(),
size(), errorDetermination);
425 template <Geometry::Estimator::EstimatorType tEstimator>
436 worker->
executeFunction(
Worker::Function::create(*
this, &PoseProjectionSet::findPoseWithMinimalErrorSubset<tEstimator>, imagePoints, numberImagePoints, validImagePoints, errorDetermination, errorObjects.
data(), 0u, 0u), 0u,
size(), 5u, 6u);
438 findPoseWithMinimalErrorSubset<tEstimator>(imagePoints, numberImagePoints, validImagePoints, errorDetermination, errorObjects.
data(), 0u, (
unsigned int)
size());
440 std::sort(errorObjects.begin(), errorObjects.end());
443 *resultingError = errorObjects.front().error();
449 template <Geometry::Estimator::EstimatorType tEstimator>
454 if (
isEmpty() || numberPoses == 0)
460 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());
467 std::sort(errorObjects.begin(), errorObjects.end());
469 const size_t results = min(numberPoses, errorObjects.size());
471 for (
size_t n = 0; n < results; ++n)
475 resultingErrors[n] = errorObjects[n].error();
478 return (
unsigned int)results;
481 template <Geometry::Estimator::EstimatorType tEstimator>
484 ocean_assert(imagePoints);
485 ocean_assert(errorObjects);
489 for (
unsigned int n = firstProjection; n < firstProjection + numberProjections; ++n)
491 const Scalar errorValue =
projectionSetPoseProjections[n].minimalAverageSquareError<tEstimator>(imagePoints, numberImagePoints, validImagePoints, errorDetermination);
DistortionState
Definition of individual distortion states.
Definition: PointFeature.h:51
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:3023
ErrorDetermination
Definition of different error determination stages.
Definition: Error.h:41
static constexpr T maxValue()
Returns the max scalar value.
Definition: Numeric.h:3244
This class implements a pose projection.
Definition: PoseProjection.h:38
PoseProjection(const HomogenousMatrix4 &pose, const PinholeCamera &pinholeCamera, const Geometry::ObjectPoint *objectPoints, const size_t number, const bool distortImagePoints)
Creates a new pose projection object by a given pose and object points.
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:414
const Geometry::ImagePoints & imagePoints() const
Returns the image points (the projected object points) of this pose projection.
Definition: PoseProjection.h:325
PoseProjection()
Creates an empty pose projection object.
const HomogenousMatrix4 & pose() const
Returns the pose of this projection.
Definition: PoseProjection.h:320
HomogenousMatrix4 poseTransformation
Pose of this projection.
Definition: PoseProjection.h:117
CV::Detector::PointFeature::DistortionState poseDistortionState
Distortion state of the image points.
Definition: PoseProjection.h:123
size_t size() const
Returns the number of stored pose points.
Definition: PoseProjection.h:335
CV::Detector::PointFeature::DistortionState distortionState() const
Returns the distortion state of this projection.
Definition: PoseProjection.h:330
Geometry::ImagePoints poseImagePoints
Projection object points for this pose.
Definition: PoseProjection.h:120
bool isEmpty() const
Returns whether this pose projection holds no points.
Definition: PoseProjection.h:340
static const Vector3 & objectPoint2objectPoint(const Geometry::ObjectPoint &element)
Converts an element to an object point.
Definition: PoseProjection.h:315
This class implements a error object.
Definition: PoseProjection.h:143
bool operator<(const ErrorObject &object) const
Returns whether the left object has a lesser error value than the right one.
Definition: PoseProjection.h:408
unsigned int objectIndex
Object index.
Definition: PoseProjection.h:175
Scalar error() const
Returns the error of this object.
Definition: PoseProjection.h:403
Scalar objectError
Object error.
Definition: PoseProjection.h:178
ErrorObject(const unsigned int index, const Scalar error)
Creates a new error object.
Definition: PoseProjection.h:391
unsigned int index() const
Returns the index of this object.
Definition: PoseProjection.h:398
This class implements a set of pose projections.
Definition: PoseProjection.h:131
unsigned int projectionSetCameraHeight
Height of the camera in pixel used for all pose projections.
Definition: PoseProjection.h:312
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:426
const PoseProjections & poseProjections() const
Returns the registered pose projections.
Definition: PoseProjection.h:371
~PoseProjectionSet()
Destructs a set of pose projections.
PoseProjectionSet()
Creates an empty set of pose projections.
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:450
bool isEmpty() const
Returns whether this set holds no pose projections.
Definition: PoseProjection.h:381
void setDimension(const unsigned int width, const unsigned int height)
Sets the dimension of the camera used for all pose projections.
Definition: PoseProjection.h:360
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:482
std::vector< ErrorObject > ErrorObjects
Definition of a vector holding error objects.
Definition: PoseProjection.h:184
void clear()
Clears the projection set.
unsigned int projectionSetCameraWidth
Width of the camera in pixel used for all pose projections.
Definition: PoseProjection.h:309
PoseProjections projectionSetPoseProjections
All registered pose projections.
Definition: PoseProjection.h:306
void addPoseProjection(const PoseProjection &poseProjection)
Adds a new pose projection.
Definition: PoseProjection.h:366
unsigned int width() const
Returns the width of the camera in pixel used for all projections.
Definition: PoseProjection.h:350
std::vector< PoseProjection > PoseProjections
Definition of a vector holding pose projections.
Definition: PoseProjection.h:137
size_t size() const
Returns the number of registered pose projections.
Definition: PoseProjection.h:376
unsigned int height() const
Returns the height of the camera in pixel used for all projections.
Definition: PoseProjection.h:355
const T * data() const noexcept
Returns an pointer to the vector elements.
Definition: Vector2.h:722
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
float Scalar
Definition of a scalar type.
Definition: Math.h:128
HomogenousMatrixT4< Scalar > HomogenousMatrix4
Definition of the HomogenousMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag eit...
Definition: HomogenousMatrix4.h:37
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15