1 | /******************************************************************************* |
2 | * Copyright (C) 2023 Intel Corporation |
3 | * |
4 | * SPDX-License-Identifier: MIT |
5 | ******************************************************************************/ |
6 | |
7 | #ifndef VAS_OT_TRACKET_HPP |
8 | #define VAS_OT_TRACKET_HPP |
9 | |
10 | #include "kalman_filter/kalman_filter_no_opencv.hpp" |
11 | |
12 | #include <vas/common.hpp> |
13 | |
14 | #include <cstdint> |
15 | #include <deque> |
16 | |
17 | namespace vas { |
18 | namespace ot { |
19 | |
20 | const int32_t kNoMatchDetection = -1; |
21 | |
22 | enum Status { |
23 | ST_DEAD = -1, // dead |
24 | ST_NEW = 0, // new |
25 | ST_TRACKED = 1, // tracked |
26 | ST_LOST = 2 // lost but still alive (in the detection phase if it configured) |
27 | }; |
28 | |
29 | struct Detection { |
30 | cv::Rect2f rect; |
31 | int32_t class_label = -1; |
32 | int32_t index = -1; |
33 | }; |
34 | |
35 | class Tracklet { |
36 | public: |
37 | Tracklet(); |
38 | virtual ~Tracklet(); |
39 | |
40 | public: |
41 | void ClearTrajectory(); |
42 | void InitTrajectory(const cv::Rect2f &bounding_box); |
43 | void AddUpdatedTrajectory(const cv::Rect2f &bounding_box, const cv::Rect2f &corrected_box); |
44 | void UpdateLatestTrajectory(const cv::Rect2f &bounding_box, const cv::Rect2f &corrected_box); |
45 | virtual void RenewTrajectory(const cv::Rect2f &bounding_box); |
46 | |
47 | virtual std::deque<cv::Mat> *GetRgbFeatures(); |
48 | virtual std::string Serialize() const; // Returns key:value with comma separated format |
49 | |
50 | public: |
51 | int32_t id; // If hasnot been assigned : -1 to 0 |
52 | int32_t label; |
53 | int32_t association_idx; |
54 | Status status; |
55 | int32_t age; |
56 | float confidence; |
57 | |
58 | float occlusion_ratio; |
59 | float association_delta_t; |
60 | int32_t association_fail_count; |
61 | |
62 | std::deque<cv::Rect2f> trajectory; |
63 | std::deque<cv::Rect2f> trajectory_filtered; |
64 | cv::Rect2f predicted; // Result from Kalman prediction. It is for debugging (OTAV) |
65 | mutable std::vector<std::string> otav_msg; // Messages for OTAV |
66 | }; |
67 | |
68 | class ZeroTermImagelessTracklet : public Tracklet { |
69 | public: |
70 | ZeroTermImagelessTracklet(); |
71 | virtual ~ZeroTermImagelessTracklet(); |
72 | |
73 | void RenewTrajectory(const cv::Rect2f &bounding_box) override; |
74 | |
75 | public: |
76 | int32_t birth_count; |
77 | std::unique_ptr<KalmanFilterNoOpencv> kalman_filter; |
78 | }; |
79 | |
80 | class ShortTermImagelessTracklet : public Tracklet { |
81 | public: |
82 | ShortTermImagelessTracklet(); |
83 | virtual ~ShortTermImagelessTracklet(); |
84 | |
85 | void RenewTrajectory(const cv::Rect2f &bounding_box) override; |
86 | |
87 | public: |
88 | std::unique_ptr<KalmanFilterNoOpencv> kalman_filter; |
89 | }; |
90 | |
91 | }; // namespace ot |
92 | }; // namespace vas |
93 | |
94 | #endif // VAS_OT_TRACKET_HPP |
95 | |