SSCMA-Micro CPP SDK  v2.0.0
SSCMA-Micro is a cross-platform machine learning inference framework designed for embedded devices.
kalman_filter.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_KALMAN_FILTER_H_
9 #define _BYTETRACK_KALMAN_FILTER_H_
10 
11 #include <cfloat>
12 #include <cstddef>
13 #include <cstdint>
14 #include <vector>
15 
16 #include "Eigen/Cholesky"
17 #include "Eigen/Dense"
18 
19 typedef Eigen::Matrix<float, 1, 4, Eigen::RowMajor> DETECTBOX;
20 typedef Eigen::Matrix<float, -1, 4, Eigen::RowMajor> DETECTBOXSS;
21 typedef Eigen::Matrix<float, 1, 128, Eigen::RowMajor> FEATURE;
22 typedef Eigen::Matrix<float, Eigen::Dynamic, 128, Eigen::RowMajor> FEATURESS;
23 
24 typedef Eigen::Matrix<float, 1, 8, Eigen::RowMajor> KAL_MEAN;
25 typedef Eigen::Matrix<float, 8, 8, Eigen::RowMajor> KAL_COVA;
26 typedef Eigen::Matrix<float, 1, 4, Eigen::RowMajor> KAL_HMEAN;
27 typedef Eigen::Matrix<float, 4, 4, Eigen::RowMajor> KAL_HCOVA;
28 
29 using KAL_DATA = std::pair<KAL_MEAN, KAL_COVA>;
30 using KAL_HDATA = std::pair<KAL_HMEAN, KAL_HCOVA>;
31 
32 using RESULT_DATA = std::pair<int, DETECTBOX>;
33 
34 using TRACKER_DATA = std::pair<int, FEATURESS>;
35 using MATCH_DATA = std::pair<int, int>;
36 
37 typedef Eigen::Matrix<float, -1, -1, Eigen::RowMajor> DYNAMICM;
38 
39 class KalmanFilter {
40  public:
41  KalmanFilter();
42 
43  KAL_DATA initiate(const DETECTBOX& measurement);
44  void predict(KAL_MEAN& mean, KAL_COVA& covariance);
45  KAL_HDATA project(const KAL_MEAN& mean, const KAL_COVA& covariance);
46  KAL_DATA update(const KAL_MEAN& mean, const KAL_COVA& covariance, const DETECTBOX& measurement);
47 
48  private:
49  Eigen::Matrix<float, 8, 8, Eigen::RowMajor> _motion_mat;
50  Eigen::Matrix<float, 4, 8, Eigen::RowMajor> _update_mat;
51 
52  float _std_weight_position;
53  float _std_weight_velocity;
54 };
55 
56 #endif
Definition: kalman_filter.h:39
void predict(KAL_MEAN &mean, KAL_COVA &covariance)
Definition: kalman_filter.cpp:57
KAL_DATA update(const KAL_MEAN &mean, const KAL_COVA &covariance, const DETECTBOX &measurement)
Definition: kalman_filter.cpp:87
KAL_DATA initiate(const DETECTBOX &measurement)
Definition: kalman_filter.cpp:28
KAL_HDATA project(const KAL_MEAN &mean, const KAL_COVA &covariance)
Definition: kalman_filter.cpp:75
KalmanFilter()
Definition: kalman_filter.cpp:14
std::pair< int, int > MATCH_DATA
Definition: kalman_filter.h:35
Eigen::Matrix< float, -1, 4, Eigen::RowMajor > DETECTBOXSS
Definition: kalman_filter.h:20
std::pair< KAL_HMEAN, KAL_HCOVA > KAL_HDATA
Definition: kalman_filter.h:30
std::pair< int, FEATURESS > TRACKER_DATA
Definition: kalman_filter.h:34
std::pair< int, DETECTBOX > RESULT_DATA
Definition: kalman_filter.h:32
Eigen::Matrix< float, 4, 4, Eigen::RowMajor > KAL_HCOVA
Definition: kalman_filter.h:27
Eigen::Matrix< float, 8, 8, Eigen::RowMajor > KAL_COVA
Definition: kalman_filter.h:25
Eigen::Matrix< float, 1, 4, Eigen::RowMajor > KAL_HMEAN
Definition: kalman_filter.h:26
std::pair< KAL_MEAN, KAL_COVA > KAL_DATA
Definition: kalman_filter.h:29
Eigen::Matrix< float, 1, 8, Eigen::RowMajor > KAL_MEAN
Definition: kalman_filter.h:24
Eigen::Matrix< float, Eigen::Dynamic, 128, Eigen::RowMajor > FEATURESS
Definition: kalman_filter.h:22
Eigen::Matrix< float, 1, 4, Eigen::RowMajor > DETECTBOX
Definition: kalman_filter.h:19
Eigen::Matrix< float, -1, -1, Eigen::RowMajor > DYNAMICM
Definition: kalman_filter.h:37
Eigen::Matrix< float, 1, 128, Eigen::RowMajor > FEATURE
Definition: kalman_filter.h:21