-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter.h
112 lines (90 loc) · 2.64 KB
/
filter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "Matrix.h"
#include "public.h"
#include <opencv2/opencv.hpp>
#include <math.h>
#include <opencv/cv.h>
#include <opencv/cxcore.h>
#include <opencv/highgui.h>
#include <opencv/cvaux.h>
#ifndef _FILTER_H_
#define _FILTER_H_
using namespace ljxMat;
using namespace cv;
class Filter
{
private:
static const int Median_limit = 9;
Joint Medians[Median_limit + 1];
int Median_count = 0;
int Median_num = 0;
static const int Average_limit = 9;
Joint Averages[Average_limit + 1];
int Average_Coe[Average_limit];
int Average_count = 0;
int Average_num = 0;
static const int Polynal_limit = 4;
Joint Polynals[Polynal_limit + 1];
int Polynal_count = 0;
int Polynal_num = 0;
static const int Kalman_limit = 5;
Joint Kalmans[Kalman_limit + 1];
int Kalman_count = 0;
int Kalman_num = 0;
Matrix Kalman_ex;/*(4, 4)*/
Matrix Kalman_ey;/*(4, 4)*/
Matrix Kalman_vx;/*(1, 1)*/
Matrix Kalman_vy;/*(1, 1)*/
Matrix Kalman_C ;/*(1, 4)*/
Matrix Kalman_Sx;/*(4, 1)*/
Matrix Kalman_Sy;/*(4, 1)*/
Matrix Kalman_Gx;/*(4, 1)*/
Matrix Kalman_Gy;/*(4, 1)*/
struct Particle_Filter {
static const int stateNum=4;
static const int measureNum=2;
static const int sampleNum=200;
//CvPoint保存的是int整数,所以这里要大一些
const int winHeight=10000;
const int winWidth=10000;
CvConDensation* condens;
CvMat* lowerBound;
CvMat* upperBound;
bool isPredictOnly=false;
void init();
Joint process(Joint joint);
} particleFilter;
public:
Filter();
void Median(Joint joint, double &dx, double &dy);
void Median_Clear();
JOINTS Filter_Median_Gen(JOINTS joints);
Joint Filter_Median(Joint now);
void Average(Joint joint, double &dx, double &dy);
void Average_Clear();
Joint Filter_Average(Joint now);
JOINTS Filter_Average_Gen(JOINTS joints);
void Polynal(Joint joint, double &dx, double &dy);
void Polynal_Clear();
Joint Filter_Polynal(Joint now);
JOINTS Filter_Polynal_Gen(JOINTS joints);
void Kalman(Joint joint, double &dx, double &dy);
void Kalman_Clear();
void Kalman_Set(Matrix C, Matrix vx, Matrix vy, Matrix ex, Matrix ey);
Joint Filter_Kalman(Joint now);
Joint JoyStick(Joint joint);
// Least Square Approximation
const double LS_t0 = 0.65;
const double LS_delta = 0.1;
vector<Joint> LS_List;
Mat LS_A;
int LS_n;
int LS_m;
int LS_count;
void LeastSquareInit(int n, int m = 4);
Joint Filter_LeastSquare(Joint joint);
void Particle(Joint joint, double &dx, double &dy);
//void Particle_Clear();
//void Particle_Set(Matrix C, Matrix vx, Matrix vy, Matrix ex, Matrix ey);
Joint Filter_Particle(Joint now);
};
#endif