MCPcopy Create free account
hub / github.com/davisking/dlib / perform_test

Method perform_test

dlib/test/correlation_tracker.cpp:33–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31 }
32
33 void perform_test (
34 )
35 {
36 dlog << LINFO << "perform_test()";
37
38 typedef const std::string(*frame_fn_type)();
39 // frames from examples folder
40 frame_fn_type frames[] = { &get_decoded_string_frame_000100,
41 &get_decoded_string_frame_000101,
42 &get_decoded_string_frame_000102,
43 &get_decoded_string_frame_000103
44 };
45 // correct tracking rectangles - recorded by successful runs
46 drectangle correct_rects[] = {drectangle(74, 67, 111, 152),
47 drectangle(76.025, 72.634, 112.799, 157.114),
48 drectangle(78.6849, 78.504, 115.413, 162.88),
49 drectangle(82.7572, 83.6035, 120.319, 169.895)
50 };
51 // correct update results - recorded by successful runs
52 double correct_update_results[] = { 0, 18.3077, 16.8406, 13.1716 };
53
54 correlation_tracker tracker;
55 std::istringstream sin(frames[0]());
56 array2d<unsigned char> img;
57 load_bmp(img, sin);
58 tracker.start_track(img, centered_rect(point(93, 110), 38, 86));
59 for (unsigned i = 1; i < sizeof(frames) / sizeof(frames[0]); ++i)
60 {
61 std::istringstream sin(frames[i]());
62 load_bmp(img, sin);
63
64 double res = tracker.update(img);
65 double correct_res = correct_update_results[i];
66 double res_diff = abs(correct_res - res);
67
68 drectangle pos = tracker.get_position();
69 drectangle correct_pos = correct_rects[i];
70 drectangle pos_intresect = pos.intersect(correct_pos);
71 double pos_area = pos.area();
72 double intersect_area = pos_intresect.area();
73 double rect_confidence = intersect_area / pos_area;
74
75 dlog << LINFO << "Frame #" << i << " res: " << res << " correct res: " << correct_res << " pos: " << pos
76 << " correct pos: " << correct_pos << " rect confidence: " << rect_confidence;
77
78 // small error possible due to rounding and different optimization options
79 DLIB_TEST(res_diff <= 1);
80 DLIB_TEST(rect_confidence >= 0.97);
81 print_spinner();
82 }
83 }
84
85 // ------------------------------------------------------------------------------------
86

Callers

nothing calls this directly

Calls 11

load_bmpFunction · 0.85
centered_rectFunction · 0.85
absFunction · 0.85
print_spinnerFunction · 0.85
start_trackMethod · 0.80
get_positionMethod · 0.80
drectangleClass · 0.50
pointClass · 0.50
updateMethod · 0.45
intersectMethod · 0.45
areaMethod · 0.45

Tested by

no test coverage detected