VAT  3.0
Video Analysis Tool
kalmanfilter.h
1 #ifndef KALMANFILTER_H
2 #define KALMANFILTER_H
3 
4 #include <opencv2/core/core.hpp>
5 #include <opencv2/highgui/highgui.hpp>
6 
8 {
9 public:
10  KalmanFilter();
11  KalmanFilter(int state_vector_size, int measurement_vector_size);
12 
13  cv::Mat F; //Prediction matrix
14  cv::Mat P; //Prediction covariance
15  cv::Mat H; //Measurement matrix
16  cv::Mat R; //Error Matrix (measurements - related to covariance)
17  cv::Mat K; //Kalman gain
18  cv::Mat a; //State
19  cv::Mat a_p; //Predicted state
20  cv::Mat y; //Difference: y = H a
21 
22  int states; //Number of states
23  int measurements; //Number of measurements
24  bool initial;
25  bool built;
26 
27  //Build every matrix and vector
28  void build(int state_vector_size, int measurement_vector_size);
29 
30  void updateP(cv::Mat newP);
31  void updateH(cv::Mat newH);
32 
33 
34  //Makes all Kalman process at once
35  void apply(cv::Mat measurement, cv::Mat measurement_error,
36  cv::Mat Perror);
37 
38  //Initialize everything for the first time
39  void init(cv::Mat measurement, cv::Mat measurement_error);
40 
41  //Applies F to current state a;
42  void predictState(cv::Mat Perror); //Step 1
43 
44  //Input is a measurement vector
45  void getResidual(cv::Mat mesurement); //Step2
46 
47  //Input is a covariance matrix of the measurement
48  void getKalmanGain(cv::Mat measurement_error);
49 
50  void updateState();
51 
52  cv::Mat identity(int N);
53 
54 };
55 
56 #endif // KALMANFILTER_H
Definition: kalmanfilter.h:7