8 #ifndef META_OCEAN_TRACKING_OCULUSTAGS_OCULUSTAGTRACKER_H
9 #define META_OCEAN_TRACKING_OCULUSTAGS_OCULUSTAGTRACKER_H
106 TPG_CORNERS_0_TO_3 = 1u << 0u,
109 TPG_CORNERS_4_TO_D = 1u << 1u,
112 TPG_CORNERS_0_TO_D = TPG_CORNERS_0_TO_3 | TPG_CORNERS_4_TO_D,
115 TPG_CORNERS_IN_DATA_MATRIX = 1u << 2u,
118 TPG_CORNERS_ALL_AVAILABLE = TPG_CORNERS_0_TO_D | TPG_CORNERS_IN_DATA_MATRIX,
121 TPG_DATA_MATRIX_MODULE_CENTERS = 1u << 3u,
124 TPG_FOREGROUND_MODULE_CENTERS = 1u << 4u,
127 TPG_BACKGROUND_MODULE_CENTERS = 1u << 5u,
130 TPG_ORIENTATION_MODULE_CENTERS = 1u << 6u,
175 inline size_t size()
const;
181 inline bool empty()
const;
252 inline const Vectors3& latestTrackingObjectPoints()
const;
258 inline const Vectors2& latestTrackingImagePoints()
const;
336 inline bool operator<(
const TrackedTag& otherTrackedTag)
const;
641 static constexpr uint32_t frameBorder_ = 10u;
644 static constexpr uint32_t minIntensityThreshold_ = 10u;
647 static constexpr
size_t numberRequiredObservationForStatic_ = 5;
650 static constexpr
size_t numberMaxAllowedObservations_ = 15;
653 static constexpr
unsigned int detectionCadence_ = 15u;
659 static constexpr
unsigned int numberFrameLayers_ = 6u;
664 ocean_assert(world_T_camera.
isValid());
665 ocean_assert(objectPoints.empty() ==
false);
666 ocean_assert(objectPoints.size() == imagePoints.size());
667 ocean_assert(trackingImagePoints.size() >= 4);
668 ocean_assert(trackingImagePoints.size() == trackingObjectPoints.size());
679 if (otherObservationHistory.
empty())
690 ocean_assert(otherObservationHistory.
empty());
691 ocean_assert(otherCameraPoses_world_T_camera.size() != 0);
692 ocean_assert(otherCameraPoses_world_T_camera.size() == otherObjectPointsGroup.size());
693 ocean_assert(otherCameraPoses_world_T_camera.size() == otherImagePointsGroup.size());
694 ocean_assert(otherCameraPoses_world_T_camera.size() == otherTrackingImagePointsGroup.size());
695 ocean_assert(otherCameraPoses_world_T_camera.size() == otherTrackingObjectPointsGroup.size());
697 for (
size_t i = 0; i < otherCameraPoses_world_T_camera.size(); ++i)
699 addObservation(otherCameraPoses_world_T_camera[i], std::move(otherObjectPointsGroup[i]), std::move(otherImagePointsGroup[i]), std::move(otherTrackingImagePointsGroup[i]), std::move(otherTrackingObjectPointsGroup[i]));
705 ocean_assert(cameraPoses_world_T_camera_.size() == objectPointsGroups_.size());
706 ocean_assert(cameraPoses_world_T_camera_.size() == imagePointsGroups_.size());
707 ocean_assert(cameraPoses_world_T_camera_.size() == trackingImagePointsGroups_.size());
708 ocean_assert(cameraPoses_world_T_camera_.size() == trackingObjectPointsGroups_.size());
710 return cameraPoses_world_T_camera_.size();
715 ocean_assert(cameraPoses_world_T_camera_.size() == objectPointsGroups_.size());
716 ocean_assert(cameraPoses_world_T_camera_.size() == imagePointsGroups_.size());
717 ocean_assert(cameraPoses_world_T_camera_.size() == trackingImagePointsGroups_.size());
718 ocean_assert(cameraPoses_world_T_camera_.size() == trackingObjectPointsGroups_.size());
720 return cameraPoses_world_T_camera_.empty();
725 cameraPoses_world_T_camera_.clear();
726 objectPointsGroups_.clear();
727 imagePointsGroups_.clear();
728 trackingImagePointsGroups_.clear();
729 trackingObjectPointsGroups_.clear();
734 return cameraPoses_world_T_camera_;
739 return cameraPoses_world_T_camera_;
744 return objectPointsGroups_;
749 return objectPointsGroups_;
754 return imagePointsGroups_;
759 return imagePointsGroups_;
764 return trackingObjectPointsGroups_;
769 return trackingObjectPointsGroups_;
774 return trackingImagePointsGroups_;
779 return trackingImagePointsGroups_;
784 ocean_assert(empty() ==
false);
785 ocean_assert(trackingObjectPointsGroups_.back().size() == trackingImagePointsGroups_.back().size());
787 return trackingObjectPointsGroups_.back();
792 ocean_assert(empty() ==
false);
793 ocean_assert(trackingObjectPointsGroups_.back().size() == trackingImagePointsGroups_.back().size());
795 return trackingImagePointsGroups_.back();
800 tag_ = otherTrackedTag.
tag_;
809 *
this = std::move(otherTrackedTag);
813 tag_(std::move(tag)),
814 tagObservationHistoryA_(std::move(tagObservationHistoryA)),
815 tagObservationHistoryB_(std::move(tagObservationHistoryB)),
816 trackingState_(trackingState),
817 motionType_(motionType)
825 ocean_assert(tag_.isValid() && otherTrackedTag.
tag_.
isValid());
826 return tag_.tagID() < otherTrackedTag.
tag_.
tagID();
831 if (
this != &otherTrackedTag)
833 tag_ = std::move(otherTrackedTag.tag_);
834 tagObservationHistoryA_ = std::move(otherTrackedTag.tagObservationHistoryA_);
835 tagObservationHistoryB_ = std::move(otherTrackedTag.tagObservationHistoryB_);
836 trackingState_ = otherTrackedTag.trackingState_;
837 motionType_ = otherTrackedTag.motionType_;
This class implements the abstract base class for all AnyCamera objects.
Definition: AnyCamera.h:130
This class implements a frame pyramid.
Definition: FramePyramid.h:37
This class implements Ocean's image class.
Definition: Frame.h:1792
bool isValid() const
Returns whether this matrix is a valid homogeneous transformation.
Definition: HomogenousMatrix4.h:1806
A history of tag observations for one camera Each observation consists of a camera pose,...
Definition: OculusTagTracker.h:139
const Geometry::ImagePointGroups & imagePointsGroups() const
Returns the image points stored in this instance.
Definition: OculusTagTracker.h:752
size_t removeObservations(const AnyCamera &anyCamera, const HomogenousMatrix4 &tag_T_world, const Scalar maximalError, const Scalar maximalOutliersPercent=Scalar(0.1))
Remove all observations in that do not match the specified pose This function starts with the newest ...
static bool optimizePose(const AnyCamera &anyCameraA, const AnyCamera &anyCameraB, const TagObservationHistory &tagObservationHistoryA, const TagObservationHistory &tagObservationHistoryB, const HomogenousMatrix4 &unoptimized_world_T_tag, HomogenousMatrix4 &optimized_world_T_tag)
Stereoscopic optimization of the world-to-tag transformation using the stored object-image point corr...
void addObservation(const HomogenousMatrix4 &world_T_camera, Vectors3 &&objectPoints, Vectors2 &&imagePoints, Vectors2 &&trackingImagePoints, Vectors3 &&trackingObjectPoints)
Adds a single observation of a tag to the collection.
Definition: OculusTagTracker.h:662
void append(TagObservationHistory &observationHistory)
Appends a collection of observations.
Definition: OculusTagTracker.h:677
bool empty() const
Returns true if no observations are stored in this instance.
Definition: OculusTagTracker.h:713
bool optimizePose(const AnyCamera &anyCamera, const HomogenousMatrix4 &unoptimized_world_T_tag, HomogenousMatrix4 &optimized_world_T_tag)
Monoscopic optimization of the world-to-tag transformation using the stored object-image point corres...
size_t size() const
Returns the number of observations.
Definition: OculusTagTracker.h:703
HomogenousMatrices4 cameraPoses_world_T_camera_
The world-to-camera transformations.
Definition: OculusTagTracker.h:284
const Geometry::ObjectPointGroups & trackingObjectPointsGroups() const
Returns the tracking object points stored in this instance.
Definition: OculusTagTracker.h:762
Geometry::ImagePointGroups trackingImagePointsGroups_
The image points that should be used to track the tag from frame to frame (temporally)
Definition: OculusTagTracker.h:293
const HomogenousMatrices4 & cameraPoses_world_T_camera() const
Returns the world-to-camera transformations.
Definition: OculusTagTracker.h:732
const Vectors3 & latestTrackingObjectPoints() const
Returns the latest object points that should be used for tracking.
Definition: OculusTagTracker.h:782
Geometry::ObjectPointGroups trackingObjectPointsGroups_
The image points that should be used to track the tag from frame to frame (temporally)
Definition: OculusTagTracker.h:296
void clear()
Removes all stored observations stored in this instance.
Definition: OculusTagTracker.h:723
Geometry::ImagePointGroups imagePointsGroups_
The image points corresponding to the object points at the given camera pose.
Definition: OculusTagTracker.h:290
const Vectors2 & latestTrackingImagePoints() const
Returns the latest image points that should be used for tracking.
Definition: OculusTagTracker.h:790
Geometry::ObjectPointGroups objectPointsGroups_
The object points of the tag (in reference frame of the tag)
Definition: OculusTagTracker.h:287
const Geometry::ObjectPointGroups & objectPointsGroups() const
Returns the objects points stored in the instance.
Definition: OculusTagTracker.h:742
const Geometry::ImagePointGroups & trackingImagePointsGroups() const
Returns the tracking image points stored in this instance.
Definition: OculusTagTracker.h:772
std::vector< Frame > Frames
Definition of a vector holding padding frames.
Definition: Frame.h:1755
std::vector< ObjectPoints > ObjectPointGroups
Definition of a vector holding object points, so we have groups of object points.
Definition: geometry/Geometry.h:135
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
SharedAnyCamerasT< Scalar > SharedAnyCameras
Definition of a vector holding AnyCamera objects.
Definition: AnyCamera.h:90
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition: Vector3.h:65
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15