49 TS_UNKNOWN_STATE = 0u,
71 unsigned int detectionCadence_ = 15u;
74 unsigned int trackingNumberFramePyramidLayers_ = 3u;
86 bool detectInvertedReflectance_ =
false;
141 inline Scalar codeSize()
const;
153 inline const Timestamp& trackingTimestamp()
const;
159 inline bool isValid()
const;
165 inline const Vectors3& trackingObjectPoints()
const;
180 inline void setTrackingLost();
321 inline bool isForceDetectionOnlyAndAllow2DCodesEnabled()
const;
351 static bool trackQRCode(
const SharedAnyCamera& previousSharedAnyCameraA,
const SharedAnyCamera& previousSharedAnyCameraB,
const HomogenousMatrix4& previousWorld_T_device,
const HomogenousMatrix4& previousDevice_T_cameraA,
const HomogenousMatrix4& previousDevice_T_cameraB,
const SharedAnyCamera& sharedAnyCameraA,
const SharedAnyCamera& sharedAnyCameraB,
const HomogenousMatrix4& world_T_device,
const HomogenousMatrix4& device_T_cameraA,
const HomogenousMatrix4& device_T_cameraB,
const CV::FramePyramid& previousFramePyramidA,
const CV::FramePyramid& previousFramePyramidB,
const CV::FramePyramid& framePyramidA,
const CV::FramePyramid& framePyramidB,
const Timestamp& trackingTimestamp,
TrackedQRCode& trackedCode);
422 unsigned int frameCounter_ = 0u;
437 bool forceDetectionOnlyAndAllow2DCodes_ =
false;
447 return world_T_code_;
457 return trackingState_;
462 return trackingTimestamp_;
467 return code_.
isValid() && world_T_code_.isValid() && codeSize_ >
Scalar(0) && trackingState_ !=
TS_UNKNOWN_STATE && trackingTimestamp_.isValid() && trackingObjectPoints_.size() >= 3;
472 return trackingObjectPoints_;
477 if (world_T_code.isValid() && codeSize >
Scalar(0) && trackingTimestamp.
isValid() && (!trackingTimestamp_.isValid() || trackingTimestamp >= trackingTimestamp_))
479 world_T_code_ = std::move(world_T_code);
480 codeSize_ = codeSize;
481 trackingTimestamp_ = trackingTimestamp;
487 Log::error() <<
"Failed to updated the tracking pose!";
488 ocean_assert(
false &&
"Failed to updated the tracking pose!");
500 return observationHistories_;
This class implements a 6-DOF detector for QR codes.
Definition QRCodeDetector3D.h:41
Definition of a QR code.
Definition QRCode.h:35
This class implements a frame pyramid.
Definition FramePyramid.h:46
This class implements Ocean's image class.
Definition Frame.h:1969
static MessageObject error()
Returns the message for error messages.
Definition Messenger.h:1095
This class provides basic numeric functionalities.
Definition Numeric.h:57
This class implements a timestamp.
Definition Timestamp.h:64
bool isValid() const
Returns whether the timestamp holds a valid time.
Definition Timestamp.h:646
The definition of an observation history.
Definition QRCodeTracker3D.h:221
SharedAnyCameras sharedAnyCameras_
The cameras what were used to compute these observations.
Definition QRCodeTracker3D.h:275
void addObservation(const SharedAnyCamera &sharedAnyCamera, const HomogenousMatrix4 &world_T_camera, Vectors3 &&objectPoints, Vectors2 &&imagePoints)
Adds a new observation to the observation history.
Geometry::ObjectPointGroups objectPointsGroups_
The object points of a code observation, one element per observation.
Definition QRCodeTracker3D.h:281
HomogenousMatrices4 world_T_cameras_
The camera-to-world transformations, one element per observation.
Definition QRCodeTracker3D.h:278
Geometry::ImagePointGroups imagePointsGroups_
The image points of a code observation, one element per observation.
Definition QRCodeTracker3D.h:284
size_t removeObservations(const SharedAnyCamera &sharedAnyCamera, const HomogenousMatrix4 &world_T_code, const Scalar maxProjectionError, const Scalar maxOutliersPercent)
Removes all previous observations that are taken from a different pose than the specified one.
size_t size()
Return the number of observations stored in this history.
ObservationHistory()=default
Creates an empty observation history.
void clear()
Removes all stored observations from this history.
const Vectors2 & latestImagePoints() const
Returns the latest group of image points.
const Vectors3 & latestObjectPoints() const
Returns the latest group of object points.
A tracked code.
Definition QRCodeTracker3D.h:93
TrackedQRCode(const CV::Detector::QRCodes::QRCode &code, const HomogenousMatrix4 &world_T_code, const Scalar codeSize, const Vectors3 &trackingObjectPoints, const TrackingState trackingState, const Timestamp trackingTimestamp)
Constructs a tracked code.
bool isValid() const
Returns if this tracked code is valid.
Definition QRCodeTracker3D.h:465
TrackingState trackingState() const
Returns the tracking state of the tracked code.
Definition QRCodeTracker3D.h:455
ObservationHistories & observationHistories()
Returns the list of observation histories of this code.
Definition QRCodeTracker3D.h:498
const Timestamp & trackingTimestamp() const
Returns the time stamp of the moment when this code was tracked.
Definition QRCodeTracker3D.h:460
TrackedQRCode(CV::Detector::QRCodes::QRCode &&code, HomogenousMatrix4 &&world_T_code, const Scalar codeSize, Vectors3 &&trackingObjectPoints, const TrackingState trackingState, const Timestamp trackingTimestamp)
Constructs a tracked code.
CV::Detector::QRCodes::QRCode code_
The tracked QR code.
Definition QRCodeTracker3D.h:191
TrackedQRCode()=default
Constructs an invalid tracked code.
const HomogenousMatrix4 & world_T_code() const
Returns the 6DOF pose of the tracked code.
Definition QRCodeTracker3D.h:445
ObservationHistories observationHistories_
The observation histories of the tracked QR code. One observation history per camera.
Definition QRCodeTracker3D.h:206
Scalar codeSize() const
Return the size of the code in the physical world.
Definition QRCodeTracker3D.h:450
void updateTrackingPose(HomogenousMatrix4 &&world_T_code, const Scalar codeSize, const Timestamp trackingTimestamp)
Updates the 6DOF pose of the tracked code.
Definition QRCodeTracker3D.h:475
const CV::Detector::QRCodes::QRCode & code() const
Returns the tracked code.
Definition QRCodeTracker3D.h:440
void setTrackingLost()
Sets the tracking state to lost.
Definition QRCodeTracker3D.h:492
const Vectors3 & trackingObjectPoints() const
Returns the object points that are used to track this code.
Definition QRCodeTracker3D.h:470
Vectors3 trackingObjectPoints_
The object points that this code can be tracked with.
Definition QRCodeTracker3D.h:209
This class implements a 6-DOF tracker for QR codes.
Definition QRCodeTracker3D.h:32
QRCodeTracker3D(const QRCodeTracker3D &)=delete
Disabled copy constructor.
static bool isAlreadyTracked(const TrackedQRCodesMap &trackedQRCodesMap, const CV::Detector::QRCodes::QRCode &code, const HomogenousMatrix4 &world_T_code, const Scalar codeSize, ObjectId &objectId)
Checks if a specified code is already stored in the database of tracked QR codes.
static bool trackQRCode(const SharedAnyCamera &previousSharedAnyCameraA, const SharedAnyCamera &previousSharedAnyCameraB, const HomogenousMatrix4 &previousWorld_T_device, const HomogenousMatrix4 &previousDevice_T_cameraA, const HomogenousMatrix4 &previousDevice_T_cameraB, const SharedAnyCamera &sharedAnyCameraA, const SharedAnyCamera &sharedAnyCameraB, const HomogenousMatrix4 &world_T_device, const HomogenousMatrix4 &device_T_cameraA, const HomogenousMatrix4 &device_T_cameraB, const CV::FramePyramid &previousFramePyramidA, const CV::FramePyramid &previousFramePyramidB, const CV::FramePyramid &framePyramidA, const CV::FramePyramid &framePyramidB, const Timestamp &trackingTimestamp, TrackedQRCode &trackedCode)
Tracks a single QR code from one frame to the next.
HomogenousMatrices4 previousDevice_T_cameras_
The camera poses from the previous time step.
Definition QRCodeTracker3D.h:434
bool forceDetectionOnlyAndAllow2DCodes_
Will disable tracking and run detection only; will also report back 2D codes if a 6-DOF pose is not a...
Definition QRCodeTracker3D.h:437
std::function< bool(const SharedAnyCameras &, const Frames &, const HomogenousMatrix4 &, const HomogenousMatrices4 &, CV::Detector::QRCodes::QRCodes &, HomogenousMatrices4 &, Scalars &, Worker *, const bool, const bool)> CallbackQRCodeDetection3D
Definition of a pointer to the function that provides new 6DOF detections of QR codes,...
Definition QRCodeTracker3D.h:60
bool isForceDetectionOnlyAndAllow2DCodesEnabled() const
Returns if the tracker is in detection-only mode and will report 2D codes as well.
Definition QRCodeTracker3D.h:503
std::unordered_map< ObjectId, TrackedQRCode > TrackedQRCodesMap
The definition of map of tracked QR codes.
Definition QRCodeTracker3D.h:213
TrackedQRCodesMap trackedQRCodesMap_
The database of all tracked QR codes.
Definition QRCodeTracker3D.h:416
static constexpr ObjectId invalidObjectId()
Returns an invalid object ID.
static Vectors3 createTrackingObjectPoints(const CV::Detector::QRCodes::QRCode &code, const Scalar codeSize)
Creates objects points for a code that can be used for tracking.
TrackingState
Definition of tracking states.
Definition QRCodeTracker3D.h:47
@ TS_UNKNOWN_STATE
Unknown/invalid tracking statue.
Definition QRCodeTracker3D.h:49
@ TS_TRACKING
State for currently tracked codes.
Definition QRCodeTracker3D.h:51
@ TS_LOST
State when tracking has been lost.
Definition QRCodeTracker3D.h:53
static const TrackedQRCodesMap & invalidTrackedQRCodesMap()
Returns an invalid map for tracked code.
std::vector< ObservationHistory > ObservationHistories
Vector of observation histories.
Definition QRCodeTracker3D.h:39
Parameters parameters_
The tracking parameters.
Definition QRCodeTracker3D.h:413
QRCodeTracker3D()=default
Constructs a tracker instance.
uint32_t ObjectId
The unique ID of each tracked code.
Definition QRCodeTracker3D.h:57
QRCodeTracker3D(const Parameters ¶meters, CallbackQRCodeDetection3D callbackQRCodeDetection3D=nullptr, CallbackNewQRCode callbackNewQRCode=nullptr, const bool forceDetectionOnlyAndAllow2DCodes=false)
Constructs a tracker instance with a specific detection function.
std::vector< CV::FramePyramid > previousFramePyramids_
The frames (frame pyramids) from the previous time step.
Definition QRCodeTracker3D.h:428
SharedAnyCameras previousSharedAnyCameras_
The cameras from the previous frame/time step.
Definition QRCodeTracker3D.h:425
const TrackedQRCodesMap & trackQRCodes(const SharedAnyCameras &sharedAnyCameras, const Frames &yFrames, const HomogenousMatrix4 &world_T_device, const HomogenousMatrices4 &device_T_cameras, Worker *worker=nullptr)
Tracks QR codes and their 6-DOF pose in two or more 8-bit grayscale images.
QRCodeTracker3D operator=(const QRCodeTracker3D &)=delete
Disabled assign operator.
std::function< void(const CV::Detector::QRCodes::QRCode &, const HomogenousMatrix4 &, const Scalar, const ObjectId)> CallbackNewQRCode
Definition of a function pointer that is called in the event a new QR code is detected for the first ...
Definition QRCodeTracker3D.h:63
static bool createTrackingImagePoints(const SharedAnyCamera &sharedAnyCamera, const Frame &yFrame, const HomogenousMatrix4 &world_T_camera, const HomogenousMatrix4 &world_T_code, const bool refineCorners, const Vectors3 &potentialObjectPoints, Vectors3 &objectPoints, Vectors2 &imagePoints)
Creates the object-image point pairs that can be used for tracking.
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
std::vector< Frame > Frames
Definition of a vector holding padding frames.
Definition Frame.h:1932
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
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
std::shared_ptr< AnyCamera > SharedAnyCamera
Definition of a shared pointer holding an AnyCamera object with Scalar precision.
Definition AnyCamera.h:61
std::vector< HomogenousMatrix4 > HomogenousMatrices4
Definition of a vector holding HomogenousMatrix4 objects.
Definition HomogenousMatrix4.h:73
std::vector< Vector3 > Vectors3
Definition of a vector holding Vector3 objects.
Definition Vector3.h:65
std::vector< Scalar > Scalars
Definition of a vector holding Scalar objects.
Definition Math.h:145
SharedAnyCamerasT< Scalar > SharedAnyCameras
Definition of a vector holding AnyCamera objects.
Definition AnyCamera.h:91
std::vector< QRCode > QRCodes
Definition of a vector of QR codes.
Definition QRCode.h:28
The namespace covering the entire Ocean framework.
Definition Accessor.h:15
Definition of parameters that control the tracker.
Definition QRCodeTracker3D.h:69