KalmanBoxTracker.h 1.19 KB
#ifndef KALMANBOXTRACKER_H_
#define KALMANBOXTRACKER_H_

#include <opencv2/video/tracking.hpp>
#include <highgui.h>
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>

using namespace std;
using namespace cv;

#define FusionInterval 1
class KalmanBoxTracker
{
public:
	//int count = 0;
	int time_since_update;
	int id;
	int cls;
	int counts;  //统计类别出现的次数
	float score;
	//vector< vector<float> > history;

	vector<Point> trackLine;
	//int hits;
	int hit_streak;
	int age;
	bool istraffic;

	int TrackerTimes; //记录该轨迹最近有几帧是跟踪预测算来的,如果跟踪预测多于一定数目,可以删除。

public:
	KalmanBoxTracker(vector<float> &bbox);
	void update(vector<float> &bbox);
	vector<float> predict();
	vector<float> get_state();

	void updateTrackLine(int center_x, int center_y);

private:
	KalmanFilter KF; //创建卡尔曼滤波器对象KF
	Mat measurement;
	Mat state;// (7, 1, CV_32F);                                     //state = x
	Mat processNoise;
};

float IoU(vector<float> &bb_test, vector<float> &bb_gt);
void convert_bbox_to_z(vector<float> &bbox, vector<float> &z);
void convert_x_to_bbox(Mat &x, vector<float> &bbox);


#endif