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);
487 Log::error() <<
"Failed to updated the tracking pose!";
488 ocean_assert(
false &&
"Failed to updated the tracking pose!");
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, const bool detectInvertedReflectance=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: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
static constexpr T maxValue()
Returns the max scalar value.
Definition Numeric.h:3253
This class implements a timestamp.
Definition Timestamp.h:64
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
friend class QRCodeTracker3D
Definition QRCodeTracker3D.h:94
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.
HomogenousMatrix4 world_T_code_
The 6DOF pose of the tracked QR code.
Definition QRCodeTracker3D.h:194
Scalar codeSize_
The size of the code in the physical world .
Definition QRCodeTracker3D.h:197
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
Timestamp trackingTimestamp_
The time when this code was tracked.
Definition QRCodeTracker3D.h:203
const CV::Detector::QRCodes::QRCode & code() const
Returns the tracked code.
Definition QRCodeTracker3D.h:440
TrackingState trackingState_
The tracking state of the tracked QR code.
Definition QRCodeTracker3D.h:200
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
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
HomogenousMatrix4 previousWorld_T_device_
The device poses from the previous time step.
Definition QRCodeTracker3D.h:431
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.
unsigned int frameCounter_
The counter for frames that have been processed.
Definition QRCodeTracker3D.h:422
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
CallbackQRCodeDetection3D callbackQRCodeDetection3D_
The function pointer to the function that provides new 6DOF detections of QR codes.
Definition QRCodeTracker3D.h:407
static const TrackedQRCodesMap & invalidTrackedQRCodesMap()
Returns an invalid map for tracked code.
CallbackNewQRCode callbackNewQRCode_
The function pointer that is called in the event a new QR code is detected for the first time.
Definition QRCodeTracker3D.h:410
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.
ObjectId objectIdCounter_
The counter that is used for the assignment of ID to new codes.
Definition QRCodeTracker3D.h:419
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< ImagePoints > ImagePointGroups
Definition of a vector holding image points, so we have groups of image points.
Definition geometry/Geometry.h:141
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< Vector2 > Vectors2
Definition of a vector holding Vector2 objects.
Definition Vector2.h:64
HomogenousMatrixT4< Scalar > HomogenousMatrix4
Definition of the HomogenousMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag eit...
Definition HomogenousMatrix4.h:44
std::shared_ptr< AnyCamera > SharedAnyCamera
Definition of a shared pointer holding an AnyCamera object with Scalar precision.
Definition AnyCamera.h:61
SharedAnyCamerasT< Scalar > SharedAnyCameras
Definition of a vector holding AnyCamera objects.
Definition AnyCamera.h:91
std::vector< Scalar > Scalars
Definition of a vector holding Scalar objects.
Definition Math.h:145
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
float Scalar
Definition of a scalar type.
Definition Math.h:129
std::vector< QRCode > QRCodes
Definition of a vector of QR codes.
Definition QRCode.h:28
Namespace of the Ocean QR code Library.
Namespace of the Tracker library.
The namespace covering the entire Ocean framework.
Definition Accessor.h:15
Definition of parameters that control the tracker.
Definition QRCodeTracker3D.h:69
double trackingLostGraceTimeout_
The time for which a code that is no longer tracked is removed from the database, in seconds,...
Definition QRCodeTracker3D.h:77
unsigned int detectionCadence_
The number of frames after which the detection will be run, range: [1, infinity).
Definition QRCodeTracker3D.h:71
Scalar observationHistoryMaxProjectionError
The maximum projection error that different observations may have to be counted as identical,...
Definition QRCodeTracker3D.h:80
bool detectInvertedReflectance_
True to additionally detect bright QR codes on a dark background.
Definition QRCodeTracker3D.h:86
unsigned int trackingNumberFramePyramidLayers_
The number of layers of the image pyramid that are used for the frame-to-frame tracking of points,...
Definition QRCodeTracker3D.h:74
Scalar observationHistoryMaxOutliersPercent
The maximum amount of outliers (points) that different observations may have to be counted as identic...
Definition QRCodeTracker3D.h:83