forked from vojirt/kcf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_trax.cpp
58 lines (44 loc) · 1.67 KB
/
main_trax.cpp
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
#include <stdlib.h>
#include <trax/opencv.hpp>
#include <memory>
#include "kcf.h"
int main()
{
trax::Image img;
trax::Region reg;
std::unique_ptr<KCF_Tracker> tracker;
cv::Mat image;
cv::Rect rectangle;
trax::Server handle(trax::Metadata(TRAX_REGION_RECTANGLE, TRAX_IMAGE_PATH), trax_no_log);
while (true) {
trax::Properties prop;
int tr = handle.wait(img, reg, prop);
if (tr == TRAX_INITIALIZE) {
//create new tracker
tracker.reset(new KCF_Tracker());
rectangle = trax::region_to_rect(reg);
image = trax::image_to_mat(img);
// Dynamically configure tracker
tracker->m_use_scale = prop.get("use_scale", true);
tracker->m_use_color = prop.get("use_color", true);
tracker->m_use_subpixel_localization = prop.get("use_subpixel_localization", true);
tracker->m_use_subgrid_scale = prop.get("use_subgrid_scale", true);
tracker->m_use_multithreading = prop.get("use_multithreading", true);
tracker->m_use_cnfeat = prop.get("use_cnfeat", true);
tracker->m_use_linearkernel = prop.get("use_linearkernel", false);
tracker->init(image, rectangle);
} else if (tr == TRAX_FRAME) {
image = trax::image_to_mat(img);
if (tracker) {
tracker->track(image);
BBox_c bb = tracker->getBBox();
rectangle = bb.get_rect();
}
} else {
break;
}
trax::Region status = trax::rect_to_region(rectangle);
handle.reply(status, trax::Properties());
}
return EXIT_SUCCESS;
}