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

source code of opencv/modules/gapi/src/3rdparty/vasot/src/components/ot/tracklet.hpp