派生自 Algorithm/baseDetector

Scheaven
2021-08-11 8e10c57c7e053d8789747cf1e2c5fa78f2f65cc7
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#ifndef TRACK_H
#define TRACK_H
 
#include "dataType.h"
 
#include "kalmfilter.h"
#include "model.h"
#include "time.h"
#include "stdio.h"
#include "stdlib.h"
#include <iostream>
#include<sys/time.h>
#include "../utils/geometry_util.h"
#include <queue>
#include "../utils/queue_util.hpp"
#include "../utils/log_util.h"
#include "../utils/time_util.h"
 
using namespace std;
 
class Track
{
 
    enum TrackState {Tentative = 1, Confirmed, Deleted}; // 轨迹的状态,Tentative 是刚开始的时候,Confirmed是确认了是人的轨迹,Deleted是删除的轨迹
 
public:
    bool isCurrent;
    DETECTBOX xywh;
    Track();
    ~Track();
    Track(KAL_MEAN& mean, KAL_COVA& covariance, uint64_t track_id,
          int n_init, int max_age, const FEATURE& feature, char* img_time);
    void predit(KalmFilter *kf);
    void update(KalmFilter * const kf, const DETECTION_ROW &detection, char* img_time);
    bool mark_missed(char* img_time);
    bool is_confirmed();
    bool is_deleted();
    bool is_tentative();
    DETECTBOX to_tlwh();
    DETECTBOX to_xywh();
    int time_since_update; //累积检测不到的次数
    uint64_t track_id;
    FEATURESS features;
    float confidence;
    KAL_MEAN mean;
    KAL_COVA covariance;
 
    int hits;
    int age;
    int _n_init;
    int _max_age;
    TrackState state;
    int time_substract(struct timeval *result, struct timeval *begin,struct timeval *end);
 
public:
    // 附加的其他算法
    // 逗留
//    struct timeval last_s_time, last_e_time, last_diff_time; // 逗留的开始时间、结束时间,和持续时间
    int last_s_time, last_e_time, last_diff_time; // 逗留的开始时间、结束时间,和持续时间
    int last_time; //持续逗留时间
    bool isWander;
 
    //跌倒
    float rate; //人体身高变化率
    bool isFall;
    bool first_Fall;
    int rateScale; //判断是否逐步跌倒(短时间内)
    MinQueue<float> rate_queue;
//    struct timeval fall_s_time, fall_e_time, fall_diff_time; // 跌倒的持续时间 ,字段fall_diff_time代表了两个含义。距离最小比例的时间+累积跌倒时间
//    struct timeval min_rate_time; //最大比例的定位时间
 
    int fall_s_time, fall_e_time, fall_diff_time; // 跌倒的持续时间 ,字段fall_diff_time代表了两个含义。距离最小比例的时间+累积跌倒时间
    int min_rate_time; //最大比例的定位时间
 
 
    int fall_total_time;
    float minRate;  // 队列中的最大比例
    float hisMinRate;
    SPoint center_point, min_center_point; //重心的高度
    float human_h;
    float human_w;
 
 
 
    //奔跑
    bool is_runing_t;
    bool is_runing_p;
    bool isRuning;
    SPoint last_point;
//    struct timeval single_s_time, single_diff_time; // 单帧的结束时间可以用逗留里的时间代替
    int single_s_time, single_diff_time; // 单帧的结束时间可以用逗留里的时间代替
    int single_time; // 单帧所花销的时长(ms)
    queue<float> velocity_queue;
    float sum_velocity;
    double run_rate;
    double last_rate;
    double rate_area;
 
    // 帽子、口罩、抽烟
    bool is_hat;
    int hatScore;
    int helmetScore;
    int headScore;
 
    bool is_mask;
    int maskScore;
 
    bool is_smoke;
    int smokeScore;
 
private:
//    struct timeval start,stop,diff;
    int start,stop,diff;
    double sum_timer;
    bool init_t;
    void init_track_time();
    void featuresAppendOne(const FEATURE& f);
 
};
 
#endif // TRACK_H