49 TS_UNKNOWN_STATE = 0u,
71 unsigned int detectionCadence_ = 15u;
74 unsigned int trackingNumberFramePyramidLayers_ = 3u;
138 inline Scalar codeSize()
const;
150 inline const Timestamp& trackingTimestamp()
const;
156 inline bool isValid()
const;
177 inline void setTrackingLost();
318 inline bool isForceDetectionOnlyAndAllow2DCodesEnabled()
const;
348 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);
419 unsigned int frameCounter_ = 0u;
434 bool forceDetectionOnlyAndAllow2DCodes_ =
false;
444 return world_T_code_;
454 return trackingState_;
459 return trackingTimestamp_;
464 return code_.isValid() && world_T_code_.isValid() && codeSize_ >
Scalar(0) && trackingState_ !=
TS_UNKNOWN_STATE && trackingTimestamp_.isValid() && trackingObjectPoints_.size() >= 3;
469 return trackingObjectPoints_;
474 if (world_T_code.isValid() && codeSize >
Scalar(0) && trackingTimestamp.
isValid() && (!trackingTimestamp_.isValid() || trackingTimestamp >= trackingTimestamp_))
476 world_T_code_ = std::move(world_T_code);
477 codeSize_ = codeSize;
478 trackingTimestamp_ = trackingTimestamp;
484 Log::error() <<
"Failed to updated the tracking pose!";
485 ocean_assert(
false &&
"Failed to updated the tracking pose!");
497 return observationHistories_;
This class implements a 6-DOF detector for QR codes.
Definition: QRCodeDetector3D.h:41
static bool detectQRCodesWithPyramids(const SharedAnyCameras &sharedAnyCameras, const Frames &yFrames, const HomogenousMatrix4 &world_T_device, const HomogenousMatrices4 &device_T_cameras, QRCodes &codes, HomogenousMatrices4 &world_T_codes, Scalars &codeSizes, Worker *worker=nullptr, const bool allow2DCodes=false)
Detects QR codes their 6-DOF poses in two synchronized 8-bit grayscale images.
Definition of a QR code.
Definition: QRCode.h:35
This class implements a frame pyramid.
Definition: FramePyramid.h:37
This class implements Ocean's image class.
Definition: Frame.h:1792
static MessageObject error()
Returns the message for error messages.
Definition: Messenger.h:1074
static constexpr T maxValue()
Returns the max scalar value.
Definition: Numeric.h:3244
This class implements a timestamp.
Definition: Timestamp.h:36
bool isValid() const
Returns whether the timestamp holds a valid time.
Definition: Timestamp.h:303
The definition of an observation history.
Definition: QRCodeTracker3D.h:218
SharedAnyCameras sharedAnyCameras_
The cameras what were used to compute these observations.
Definition: QRCodeTracker3D.h:272
void addObservation(const SharedAnyCamera &sharedAnyCamera, const HomogenousMatrix4 &world_T_camera, Geometry::ObjectPoints &&objectPoints, Geometry::ImagePoints &&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:278
HomogenousMatrices4 world_T_cameras_
The camera-to-world transformations, one element per observation.
Definition: QRCodeTracker3D.h:275
Geometry::ImagePointGroups imagePointsGroups_
The image points of a code observation, one element per observation.
Definition: QRCodeTracker3D.h:281
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.
const Geometry::ObjectPoints & latestObjectPoints() const
Returns the latest group of object points.
const Geometry::ImagePoints & latestImagePoints() const
Returns the latest group of image points.
ObservationHistory()=default
Creates an empty observation history.
void clear()
Removes all stored observations from this history.
A tracked code.
Definition: QRCodeTracker3D.h:90
bool isValid() const
Returns if this tracked code is valid.
Definition: QRCodeTracker3D.h:462
TrackingState trackingState() const
Returns the tracking state of the tracked code.
Definition: QRCodeTracker3D.h:452
ObservationHistories & observationHistories()
Returns the list of observation histories of this code.
Definition: QRCodeTracker3D.h:495
const Timestamp & trackingTimestamp() const
Returns the time stamp of the moment when this code was tracked.
Definition: QRCodeTracker3D.h:457
Geometry::ObjectPoints trackingObjectPoints_
The object points that this code can be tracked with.
Definition: QRCodeTracker3D.h:206
TrackedQRCode(const CV::Detector::QRCodes::QRCode &code, const HomogenousMatrix4 &world_T_code, const Scalar codeSize, const Geometry::ObjectPoints &trackingObjectPoints, const TrackingState trackingState, const Timestamp trackingTimestamp)
Constructs a tracked code.
const Geometry::ObjectPoints & trackingObjectPoints() const
Returns the object points that are used to track this code.
Definition: QRCodeTracker3D.h:467
CV::Detector::QRCodes::QRCode code_
The tracked QR code.
Definition: QRCodeTracker3D.h:188
TrackedQRCode()=default
Constructs an invalid tracked code.
TrackedQRCode(CV::Detector::QRCodes::QRCode &&code, HomogenousMatrix4 &&world_T_code, const Scalar codeSize, Geometry::ObjectPoints &&trackingObjectPoints, const TrackingState trackingState, const Timestamp trackingTimestamp)
Constructs a tracked code.
const HomogenousMatrix4 & world_T_code() const
Returns the 6DOF pose of the tracked code.
Definition: QRCodeTracker3D.h:442
ObservationHistories observationHistories_
The observation histories of the tracked QR code. One observation history per camera.
Definition: QRCodeTracker3D.h:203
Scalar codeSize() const
Return the size of the code in the physical world.
Definition: QRCodeTracker3D.h:447
void updateTrackingPose(HomogenousMatrix4 &&world_T_code, const Scalar codeSize, const Timestamp trackingTimestamp)
Updates the 6DOF pose of the tracked code.
Definition: QRCodeTracker3D.h:472
const CV::Detector::QRCodes::QRCode & code() const
Returns the tracked code.
Definition: QRCodeTracker3D.h:437
void setTrackingLost()
Sets the tracking state to lost.
Definition: QRCodeTracker3D.h:489
This class implements a 6-DOF tracker for QR codes.
Definition: QRCodeTracker3D.h:32
QRCodeTracker3D(const QRCodeTracker3D &)=delete
Disabled copy constructor.
std::function< bool(const SharedAnyCameras &, const Frames &, const HomogenousMatrix4 &, const HomogenousMatrices4 &, CV::Detector::QRCodes::QRCodes &, HomogenousMatrices4 &, Scalars &, Worker *, const bool)> CallbackQRCodeDetection3D
Definition of a pointer to the function that provides new 6DOF detections of QR codes,...
Definition: QRCodeTracker3D.h:60
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.
static Geometry::ObjectPoints createTrackingObjectPoints(const CV::Detector::QRCodes::QRCode &code, const Scalar codeSize)
Creates objects points for a code that can be used for tracking.
HomogenousMatrices4 previousDevice_T_cameras_
The camera poses from the previous time step.
Definition: QRCodeTracker3D.h:431
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:434
static const TrackedQRCodesMap & invalidTrackedQRCodesMap()
Returns an invalid map for tracked code.
std::vector< ObservationHistory > ObservationHistories
Vector of observation histories.
Definition: QRCodeTracker3D.h:36
bool isForceDetectionOnlyAndAllow2DCodesEnabled() const
Returns if the tracker is in detection-only mode and will report 2D codes as well.
Definition: QRCodeTracker3D.h:500
TrackedQRCodesMap trackedQRCodesMap_
The database of all tracked QR codes.
Definition: QRCodeTracker3D.h:413
static constexpr ObjectId invalidObjectId()
Returns an invalid object ID.
uint32_t ObjectId
The unique ID of each tracked code.
Definition: QRCodeTracker3D.h:57
std::unordered_map< ObjectId, TrackedQRCode > TrackedQRCodesMap
The definition of map of tracked QR codes.
Definition: QRCodeTracker3D.h:210
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
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.
Parameters parameters_
The tracking parameters.
Definition: QRCodeTracker3D.h:410
QRCodeTracker3D()=default
Constructs a tracker instance.
QRCodeTracker3D(const Parameters ¶meters, CallbackQRCodeDetection3D callbackQRCodeDetection3D=nullptr, CallbackNewQRCode callbackNewQRCode=nullptr, const bool forceDetectionOnlyAndAllow2DCodes=false)
Constructs a tracker instance with a specific detection function.
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 Geometry::ObjectPoints &potentialObjectPoints, Geometry::ObjectPoints &objectPoints, Geometry::ImagePoints &imagePoints)
Creates the object-image point pairs that can be used for tracking.
std::vector< CV::FramePyramid > previousFramePyramids_
The frames (frame pyramids) from the previous time step.
Definition: QRCodeTracker3D.h:425
SharedAnyCameras previousSharedAnyCameras_
The cameras from the previous frame/time step.
Definition: QRCodeTracker3D.h:422
QRCodeTracker3D operator=(const QRCodeTracker3D &)=delete
Disabled assign operator.
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:1755
std::vector< ObjectPoint > ObjectPoints
Definition of a vector holding 3D object points.
Definition: geometry/Geometry.h:129
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< ImagePoint > ImagePoints
Definition of a vector holding 2D image points.
Definition: geometry/Geometry.h:123
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::shared_ptr< AnyCamera > SharedAnyCamera
Definition of a shared pointer holding an AnyCamera object with Scalar precision.
Definition: AnyCamera.h:60
std::vector< Scalar > Scalars
Definition of a vector holding Scalar objects.
Definition: Math.h:144
HomogenousMatrixT4< Scalar > HomogenousMatrix4
Definition of the HomogenousMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag eit...
Definition: HomogenousMatrix4.h:37
SharedAnyCamerasT< Scalar > SharedAnyCameras
Definition of a vector holding AnyCamera objects.
Definition: AnyCamera.h:90
std::vector< QRCode > QRCodes
Definition of a vector of QR codes.
Definition: QRCode.h:25
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15
Definition of parameters that control the tracker.
Definition: QRCodeTracker3D.h:69