Sort.h
2.4 KB
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
#ifndef SORT_H_
#define SORT_H_
#include "KalmanBoxTracker.h"
#include "HungarianAlgorithm.h"
#include <opencv2/video/tracking.hpp>
#include <highgui.h>
#include <iostream>
#include <stdio.h>
#include <math.h>
#include<vector>
#include "../VPT.h"
#include "TrafficStatistics.h"
using namespace std;
using namespace cv;
#define LOSTMAXFRAMECCOUNT 5 //by zl
#define SNAPSHOTFRAMECOUNT 24 //下标从0开始 取第十帧为快照帧
struct TrackerResult
{
vector< vector<float> > trackers_box;
vector< vector< vector<float> > > trackers_history;
};
typedef struct mylist
{
vector <VPT_ObjInfo> listinfo;
int lost; //丢失的帧数 >LOSTMAXFRAMECCOUNT 则认为彻底丢失目标
long id;
bool isupdate;
bool istraffic;
int index;// 行人类别
int num; // 该ID序列下的第num帧 20170306 从0开始计数
int startframe; //轨迹开始帧
int endframe; //轨迹结束帧
}mylist;
class Sort
{
public:
//Sort();
int updateLastFrame(vector<int> &deleteTrackers);
Sort(VPT_Line *m_line = NULL, int m_linecount = 0, int m_detectType = 0);
int update(int width, int height, bool isUseDet, vector< vector<float> > &dets, VPT_ObjInfo *result, vector<int> &deleteTrackers, VPT_TrafficResult* traffic = NULL, int detectType = 0);
void Release();
void ReSet();
void Pause();
bool GetState();
int addTracker(Mat *img);
public:
vector<KalmanBoxTracker> trackers;
int max_age;
int min_hits;
int frame_count; // 记录自身被调用的次数
long long int frame_count_; // 220826 byzsh 用于和外界同步帧号
int trackcount;
//---------------------添加快照保存策略-----------------------//
//vector<OBJECT_SNAPSHOT_INFO> snapshots;
private:
int linecount;
int detectType;
TrafficStatistics *mTrafficStatistics;
vector <VPT_Line> lineArray;
vector <VPT_TrafficResult> trafficArray; //统计流量
bool istraffic; //by zl 是否统计交通量
//vector <mylist> tracker;
bool WORK;
int detectObjCount;
private:
void associate_detections_to_trackers(vector< vector<int> > &matched, vector<int> &unmatched_dets, vector<int> &unmatched_trks, vector< vector<float> > &dets, vector< vector<float> > &trks, float iou_threshold = 0.3);
//int addTracker(VPT_ObjInfo *result, int resultcount);
int Traffic();
};
//辅助函数
void RectboundCheck(int Width, int Height, VPT_ObjInfo * result); //防止坐标越界 by zl
#endif