SSCMA-Micro CPP SDK  v2.0.0
SSCMA-Micro is a cross-platform machine learning inference framework designed for embedded devices.
byte_tracker.h
Go to the documentation of this file.
1 /*
2  * MIT License
3  * Copyright (c) 2021 Yifu Zhang
4  *
5  * Modified by nullptr, Aug 8, 2024, Seeed Technology Co.,Ltd
6  */
7 
8 #ifndef _BYTETRACK_BYTE_TRACKER_H_
9 #define _BYTETRACK_BYTE_TRACKER_H_
10 
11 #include <cfloat>
12 #include <climits>
13 #include <cstdint>
14 #include <vector>
15 
16 #include "core/ma_types.h"
17 #include "strack.h"
18 
19 class BYTETracker {
20 public:
21  BYTETracker(int frame_rate = 10, int track_buffer = 30, float track_thresh = 0.5, float high_thresh = 0.6, float match_thresh = 0.8, float scale_factor = 1000.0);
22  ~BYTETracker();
23 
24  std::vector<int> inplace_update(std::vector<ma_bbox_t>& objects);
25  void clear();
26 
27 protected:
28  std::vector<STrack> update(const std::vector<ma_bbox_t>& objects);
29 
30 private:
31  std::vector<STrack*> joint_stracks(std::vector<STrack*>& tlista, std::vector<STrack>& tlistb);
32  std::vector<STrack> joint_stracks(std::vector<STrack>& tlista, std::vector<STrack>& tlistb);
33 
34  std::vector<STrack> sub_stracks(std::vector<STrack>& tlista, std::vector<STrack>& tlistb);
35  void remove_duplicate_stracks(std::vector<STrack>& resa, std::vector<STrack>& resb, std::vector<STrack>& stracksa, std::vector<STrack>& stracksb);
36 
37  void linear_assignment(std::vector<std::vector<float>>& cost_matrix,
38  int cost_matrix_size,
39  int cost_matrix_size_size,
40  float thresh,
41  std::vector<std::vector<int>>& matches,
42  std::vector<int>& unmatched_a,
43  std::vector<int>& unmatched_b);
44  std::vector<std::vector<float>> iou_distance(std::vector<STrack*>& atracks, std::vector<STrack>& btracks, int& dist_size, int& dist_size_size);
45  std::vector<std::vector<float>> iou_distance(std::vector<STrack>& atracks, std::vector<STrack>& btracks);
46  std::vector<std::vector<float>> ious(std::vector<std::vector<float>>& atlbrs, std::vector<std::vector<float>>& btlbrs);
47 
48  double lapjv(const std::vector<std::vector<float>>& cost, std::vector<int>& rowsol, std::vector<int>& colsol, bool extend_cost = false, float cost_limit = LONG_MAX, bool return_cost = true);
49 
50 private:
51  float track_thresh;
52  float high_thresh;
53  float match_thresh;
54  float scale_factor;
55  int frame_id;
56  int max_time_lost;
57 
58  std::vector<STrack> tracked_stracks;
59  std::vector<STrack> lost_stracks;
60  std::vector<STrack> removed_stracks;
61  KalmanFilter kalman_filter;
62 };
63 
64 #endif
Definition: byte_tracker.h:19
~BYTETracker()
Definition: byte_tracker.cpp:35
std::vector< STrack > update(const std::vector< ma_bbox_t > &objects)
Definition: byte_tracker.cpp:69
void clear()
Definition: byte_tracker.cpp:61
std::vector< int > inplace_update(std::vector< ma_bbox_t > &objects)
Definition: byte_tracker.cpp:37
BYTETracker(int frame_rate=10, int track_buffer=30, float track_thresh=0.5, float high_thresh=0.6, float match_thresh=0.8, float scale_factor=1000.0)
Definition: byte_tracker.cpp:25
Definition: kalman_filter.h:39