#pragma once #include #include #include "track.h" #include "munkres.h" #include "utils.h" class Tracker { public: Tracker(); ~Tracker() = default; static float CalculateIou(const cv::Rect& det, const Track& track); static void HungarianMatching(const std::vector>& iou_matrix, size_t nrows, size_t ncols, std::vector>& association); /** * Assigns detections to tracked object (both represented as bounding boxes) * Returns 2 lists of matches, unmatched_detections * @param detection * @param tracks * @param matched * @param unmatched_det * @param iou_threshold */ static void AssociateDetectionsToTrackers(const std::vector& detection, std::map& tracks, std::map& matched, std::vector& unmatched_det, float iou_threshold = 0.3); void Run(const std::vector& detections); std::map GetTracks(); private: // Hash-map between ID and corresponding tracker std::map tracks_; // Assigned ID for each bounding box int id_; };