KalmanBoxTracker.h 1.42 KB
#ifndef KALMANBOXTRACKER_H_
#define KALMANBOXTRACKER_H_

#include <opencv2/opencv.hpp>
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include "CycleQueue.h"

using namespace std;

// #define FusionInterval 5 //控制算法跳帧
class KalmanBoxTracker
{
public:
	//int count = 0;
	int time_since_update = 0;
	int FusionInterval = 5; //控制算法跳帧 221117
	int id = 0;
	int cls = 0;
	float score = 0.00;
	std::vector<float> ldmk;
	//-added by zsh 220719 人脸姿态角-
	float roll = 0.0; 
	float yaw = 0.0;												
	float pitch = 0.0;
	//-------------------------------

	//vector< vector<float> > history;

	cycleQueue history;   //固定大小的轨迹
	//int hits;
	int hit_streak = 0;
	int age = 0;
	int m_trackLength = 0;

	int frame_count {1};

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);
float center_distance(vector<float> &bb_test, vector<float> &bb_gt, float maxLength); // added by zsh 220718
void convert_bbox_to_z(vector<float> &bbox, vector<float> &z);
void convert_x_to_bbox(cv::Mat &x, vector<float> &bbox);


#endif