Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
BoundingBoxTracking.h
Go to the documentation of this file.
1
12#ifndef BOUNDING_BOX_TRACKING_H
13#define BOUNDING_BOX_TRACKING_H
14
16#include <opencv2/opencv.hpp>
17#include <opencv2/tracking.hpp>
18
20
21
28namespace tracking
29{
30 // Enum class to define the different types of trackers available in OpenCV.
31 enum class TrackerType
32 {
33 eMIL, // Multi Instance Learning
34 eKCF, // Kernelized Correlation Filter
35 // eGOTURN, // Generic Object Tracking Using Regression Networks. // FIXME: Need to download the model.
36 eCSRT // Discriminative Correlation Filter with Channel and Spatial Reliability
37 };
38
39
49 {
50 public:
52 // Declare public methods.
54
55 MultiTracker(const double dTrackingLostTimeout = 1.0, const double dMaxTrackingTime = 3.0, const double dIOUThreshold = 0.3);
57 bool InitTracker(const cv::Mat& cvFrame, const std::shared_ptr<cv::Rect2d> cvBoundingBox, const TrackerType eTrackerType = TrackerType::eKCF);
58 void Update(const cv::Mat& cvFrame);
59 void ClearTrackers();
60
62 // Setters.
64 void SetTrackerLostTimeout(const double dTimeout);
65 void SetMaxTrackingTime(const double dMaxTime);
66
68 // Getters.
70 double GetTrackerLostTimeout() const;
71 double GetMaxTrackingTime() const;
72
73 private:
75 // Declare private methods.
77
78 double CalculateIOU(const cv::Rect2d& cvBoxA, const cv::Rect2d& cvBoxB);
79 cv::Ptr<cv::Tracker> CreateTracker(const TrackerType eType);
80
82 // Declare private member variables.
84 std::map<int, cv::Ptr<cv::Tracker>> m_mTrackers;
85 std::map<int, std::shared_ptr<cv::Rect2d>> m_mBoundingBoxes;
86 std::map<int, std::chrono::system_clock::time_point> m_mLastUpdateTime;
87 std::map<int, std::chrono::system_clock::time_point> m_mTimeSinceLastGroundTruthDetection;
88 double m_dTrackingLostThreshold; // Time in seconds after which a tracker is considered lost.
89 double m_dMaxTrackingTime; // Maximum time in seconds to track an object.
90 double m_dIOUThreshold; // Minimum Intersection over Union required to associate a new detection with an existing tracker.
91 int m_nNextId;
92 };
93} // namespace tracking
94
95#endif // BOUNDING_BOX_TRACKING_H
Class for tracking multiple bounding boxes in images using OpenCV. This class supports all OpenCV tra...
Definition BoundingBoxTracking.h:49
cv::Ptr< cv::Tracker > CreateTracker(const TrackerType eType)
Create a tracker based on the specified type.
Definition BoundingBoxTracking.cpp:324
double GetTrackerLostTimeout() const
Get the timeout for when a tracker is considered lost.
Definition BoundingBoxTracking.cpp:277
double CalculateIOU(const cv::Rect2d &cvBoxA, const cv::Rect2d &cvBoxB)
Calculate the Intersection over Union (IoU) of two bounding boxes.
Definition BoundingBoxTracking.cpp:305
~MultiTracker()
Destroy the Multi Tracker object.
Definition BoundingBoxTracking.cpp:54
void SetTrackerLostTimeout(const double dTimeout)
Set the timeout for when a tracker is considered lost.
Definition BoundingBoxTracking.cpp:251
void SetMaxTrackingTime(const double dMaxTime)
Set the maximum tracking time for a tracker.
Definition BoundingBoxTracking.cpp:264
void Update(const cv::Mat &cvFrame)
Initialize the MultiTracker with a new frame and a vector of bounding boxes.
Definition BoundingBoxTracking.cpp:147
void ClearTrackers()
Clear all trackers and bounding boxes from the MultiTracker.
Definition BoundingBoxTracking.cpp:225
double GetMaxTrackingTime() const
Get the maximum tracking time for a tracker.
Definition BoundingBoxTracking.cpp:290
bool InitTracker(const cv::Mat &cvFrame, const std::shared_ptr< cv::Rect2d > cvBoundingBox, const TrackerType eTrackerType=TrackerType::eKCF)
Add a new tracker for a given frame and bounding box.
Definition BoundingBoxTracking.cpp:71
std::shared_ptr< _Tp > Ptr
Namespace containing classes and functions for tracking bounding boxes in images.
Definition BoundingBoxTracking.cpp:27