Blame view

vpt/src/CD/sort/Sort.h 2.21 KB
144cd8c4   Hu Chunming   v6.0.0 替换模型
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
  #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 "../CD.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 <CD_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, CD_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;

  	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, CD_ObjInfo * result);	//防止坐标越界 by zl

  #endif