forked from Smorodov/Multitarget-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefines.h
More file actions
236 lines (212 loc) · 4.58 KB
/
defines.h
File metadata and controls
236 lines (212 loc) · 4.58 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
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#pragma once
#include <vector>
#include <string>
#include <map>
#include <opencv2/opencv.hpp>
#include "object_types.h"
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
typedef float track_t;
typedef cv::Point_<track_t> Point_t;
#define El_t CV_32F
#define Mat_t CV_32FC
typedef std::vector<int> assignments_t;
typedef std::vector<track_t> distMatrix_t;
///
template<typename T>
class TrackID
{
public:
typedef T value_type;
TrackID() = default;
TrackID(const TrackID& id) = default;
TrackID(TrackID&& id) = default;
TrackID& operator=(TrackID&& id) noexcept
{
m_val = std::move(id.m_val);
return *this;
}
TrackID& operator=(const TrackID& id) noexcept
{
m_val = id.m_val;
return *this;
}
TrackID(value_type val)
: m_val(val)
{
}
const TrackID& operator=(value_type val)
{
m_val = val;
}
bool operator==(const TrackID& id) const
{
return m_val == id.m_val;
}
std::string ID2Str() const
{
return std::to_string(m_val);
}
static TrackID Str2ID(const std::string& id)
{
return TrackID(std::stoi(id));
}
TrackID NextID() const
{
return TrackID(m_val + 1);
}
size_t ID2Module(size_t module) const
{
return m_val % module;
}
value_type m_val{ 0 };
};
typedef TrackID<size_t> track_id_t;
namespace std
{
template <>
struct hash<track_id_t>
{
std::size_t operator()(const track_id_t& k) const
{
return std::hash<track_id_t::value_type>()(k.m_val);
}
};
}
///
/// \brief config_t
///
typedef std::multimap<std::string, std::string> config_t;
///
/// \brief The CRegion class
///
class CRegion
{
public:
CRegion() = default;
CRegion(const cv::Rect& rect) noexcept
: m_brect(rect)
{
B2RRect();
}
CRegion(const cv::RotatedRect& rrect) noexcept
: m_rrect(rrect)
{
R2BRect();
}
CRegion(const cv::Rect& rect, objtype_t type, float confidence) noexcept
: m_type(type), m_brect(rect), m_confidence(confidence)
{
B2RRect();
}
objtype_t m_type = bad_type;
cv::RotatedRect m_rrect;
cv::Rect m_brect;
float m_confidence = -1;
private:
///
/// \brief R2BRect
/// \return
///
cv::Rect R2BRect() noexcept
{
m_brect = m_rrect.boundingRect();
return m_brect;
}
///
/// \brief B2RRect
/// \return
///
cv::RotatedRect B2RRect() noexcept
{
m_rrect = cv::RotatedRect(m_brect.tl(), cv::Point2f(static_cast<float>(m_brect.x + m_brect.width), static_cast<float>(m_brect.y)), m_brect.br());
return m_rrect;
}
};
typedef std::vector<CRegion> regions_t;
///
///
///
namespace tracking
{
///
/// \brief The Detectors enum
///
enum Detectors
{
Motion_VIBE = 0,
Motion_MOG = 1,
Motion_GMG = 2,
Motion_CNT = 3,
Motion_SuBSENSE = 4,
Motion_LOBSTER = 5,
Motion_MOG2 = 6,
Face_HAAR = 7,
Pedestrian_HOG = 8,
Pedestrian_C4 = 9,
Yolo_Darknet = 10,
Yolo_TensorRT = 11,
DNN_OCV = 12,
DetectorsCount
};
///
/// \brief The DistType enum
///
enum DistType
{
DistCenters, // Euclidean distance between centers, [0, 1]
DistRects, // Euclidean distance between bounding rectangles, [0, 1]
DistJaccard, // Intersection over Union, IoU, [0, 1]
DistHist, // Bhatacharia distance between histograms, [0, 1]
DistFeatureCos, // Cosine distance between embeddings, [0, 1]
DistMahalanobis, // Mahalanobis: https://ww2.mathworks.cn/help/vision/ug/motion-based-multiple-object-tracking.html
DistsCount
};
///
/// \brief The FilterGoal enum
///
enum FilterGoal
{
FilterCenter,
FilterRect,
FiltersCount
};
///
/// \brief The KalmanType enum
///
enum KalmanType
{
KalmanLinear,
KalmanUnscented,
KalmanAugmentedUnscented,
KalmanCount
};
///
/// \brief The MatchType enum
///
enum MatchType
{
MatchHungrian,
MatchBipart,
MatchCount
};
///
/// \brief The LostTrackType enum
///
enum LostTrackType
{
TrackNone,
TrackKCF,
TrackMIL,
TrackMedianFlow,
TrackGOTURN,
TrackMOSSE,
TrackCSRT,
TrackDAT,
TrackSTAPLE,
TrackLDES,
TrackDaSiamRPN,
SingleTracksCount
};
}