| 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 |
nothing calls this directly
no test coverage detected