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

Function main

examples/video_tracking_ex.cpp:25–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23using namespace std;
24
25int main(int argc, char** argv) try
26{
27 if (argc != 2)
28 {
29 cout << "Call this program like this: " << endl;
30 cout << "./video_tracking_ex ../video_frames" << endl;
31 return 1;
32 }
33
34 // Get the list of video frames.
35 std::vector<file> files = get_files_in_directory_tree(argv[1], match_ending(".jpg"));
36 std::sort(files.begin(), files.end());
37 if (files.size() == 0)
38 {
39 cout << "No images found in " << argv[1] << endl;
40 return 1;
41 }
42
43 // Load the first frame.
44 array2d<unsigned char> img;
45 load_image(img, files[0]);
46 // Now create a tracker and start a track on the juice box. If you look at the first
47 // frame you will see that the juice box is centered at pixel point(92,110) and 38
48 // pixels wide and 86 pixels tall.
49 correlation_tracker tracker;
50 tracker.start_track(img, centered_rect(point(93,110), 38, 86));
51
52 // Now run the tracker. All we have to do is call tracker.update() and it will keep
53 // track of the juice box!
54 image_window win;
55 for (unsigned long i = 1; i < files.size(); ++i)
56 {
57 load_image(img, files[i]);
58 tracker.update(img);
59
60 win.set_image(img);
61 win.clear_overlay();
62 win.add_overlay(tracker.get_position());
63
64 cout << "hit enter to process next frame" << endl;
65 cin.get();
66 }
67}
68catch (std::exception& e)
69{
70 cout << e.what() << endl;
71}
72

Callers

nothing calls this directly

Calls 15

centered_rectFunction · 0.85
start_trackMethod · 0.80
clear_overlayMethod · 0.80
get_positionMethod · 0.80
match_endingClass · 0.50
load_imageFunction · 0.50
pointClass · 0.50
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected