OpenShot Library | libopenshot  0.4.0
KalmanTracker.h
Go to the documentation of this file.
1 // © OpenShot Studios, LLC
2 //
3 // SPDX-License-Identifier: LGPL-3.0-or-later
4 
6 // KalmanTracker.h: KalmanTracker Class Declaration
7 
8 #ifndef KALMAN_H
9 #define KALMAN_H 2
10 
11 #include "opencv2/video/tracking.hpp"
12 #include "opencv2/highgui/highgui.hpp"
13 
14 
15 #define StateType cv::Rect_<float>
16 
19 {
20 public:
22  {
23  init_kf(StateType());
25  m_hits = 0;
26  m_hit_streak = 0;
27  m_age = 0;
28  m_id = 0;
29  }
30  KalmanTracker(StateType initRect, float confidence, int classId, int objectId) : confidence(confidence), classId(classId)
31  {
32  init_kf(initRect);
34  m_hits = 0;
35  m_hit_streak = 0;
36  m_age = 0;
37  m_id = objectId;
38  }
39 
41  {
42  m_history.clear();
43  }
44 
47  void update(StateType stateMat);
48 
50  StateType get_rect_xysr(float cx, float cy, float s, float r);
51 
53  int m_hits;
55  int m_age;
56  int m_id;
57  float confidence;
58  int classId;
59 
60 private:
61  void init_kf(StateType stateMat);
62 
63  cv::KalmanFilter kf;
64  cv::Mat measurement;
65 
66  std::vector<StateType> m_history;
67 };
68 
69 #endif
KalmanTracker::classId
int classId
Definition: KalmanTracker.h:58
KalmanTracker::KalmanTracker
KalmanTracker()
Definition: KalmanTracker.h:21
StateType
#define StateType
Definition: KalmanTracker.h:15
KalmanTracker::~KalmanTracker
~KalmanTracker()
Definition: KalmanTracker.h:40
KalmanTracker
This class represents the internel state of individual tracked objects observed as bounding box.
Definition: KalmanTracker.h:18
KalmanTracker::m_age
int m_age
Definition: KalmanTracker.h:55
KalmanTracker::KalmanTracker
KalmanTracker(StateType initRect, float confidence, int classId, int objectId)
Definition: KalmanTracker.h:30
KalmanTracker::get_rect_xysr
StateType get_rect_xysr(float cx, float cy, float s, float r)
Definition: KalmanTracker.cpp:103
KalmanTracker::m_id
int m_id
Definition: KalmanTracker.h:56
KalmanTracker::predict2
StateType predict2()
Definition: KalmanTracker.cpp:62
KalmanTracker::confidence
float confidence
Definition: KalmanTracker.h:57
KalmanTracker::m_time_since_update
int m_time_since_update
Definition: KalmanTracker.h:52
KalmanTracker::m_hits
int m_hits
Definition: KalmanTracker.h:53
KalmanTracker::update
void update(StateType stateMat)
Definition: KalmanTracker.cpp:73
KalmanTracker::get_state
StateType get_state()
Definition: KalmanTracker.cpp:96
KalmanTracker::m_hit_streak
int m_hit_streak
Definition: KalmanTracker.h:54
KalmanTracker::predict
StateType predict()
Definition: KalmanTracker.cpp:46