KalmanBoxTracker.h 1.1 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>
#include "CycleQueue.h"

using namespace std;

#define FusionInterval 1 //控制算法跳帧
class KalmanBoxTracker
{
public:
	//int count = 0;
	int time_since_update = 0;
	int id = 0;
	int cls = 0;
	float score = 0.00;
	//vector< vector<float> > history;

	cycleQueue history;   //固定大小的轨迹

	//int hits;
	int hit_streak = 0;
	int age = 0;
	int m_trackLength = 0;

public:
	KalmanBoxTracker(vector<float> &bbox, int trackLength);
	~KalmanBoxTracker();
	void update(vector<float> &bbox);
	vector<float> predict();
	vector<float> get_state();
private:
	cv::KalmanFilter KF; //创建卡尔曼滤波器对象KF
	cv::Mat measurement;
	cv::Mat state;// (7, 1, CV_32F);                                     //state = x
	cv::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(cv::Mat &x, vector<float> &bbox);


#endif