Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
27510c8a
Commit
27510c8a
authored
Feb 03, 2015
by
Davis King
Browse files
Added comments
parent
6fbd1cf0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
examples/video_tracking_ex.cpp
examples/video_tracking_ex.cpp
+16
-5
No files found.
examples/video_tracking_ex.cpp
View file @
27510c8a
// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
/*
/*
This is an example illustrating the use of the Bulk Synchronous Parallel (BSP)
This example shows how to use the correlation_tracker from the dlib C++ library. This
processing tools from the dlib C++ Library. These tools allow you to easily setup a
object lets you track the position of an object as it moves from frame to frame in a
number of processes running on different computers which cooperate to compute some
video sequence. To use it, you give the correlation_tracker the bounding box of the
result.
object you want to track in the current video frame. Then it will identify the
location of the object in subsequent frames.
In this particular example, we are going to run on the video sequence that comes with
dlib, which can be found in the examples/video_frames folder. This video shows a juice
box sitting on a table and someone is waving the camera around. The task is to track the
position of the juice box as the camera moves around.
*/
*/
#include <dlib/image_processing.h>
#include <dlib/image_processing.h>
...
@@ -26,6 +31,7 @@ int main(int argc, char** argv) try
...
@@ -26,6 +31,7 @@ int main(int argc, char** argv) try
return
1
;
return
1
;
}
}
// Get the list of video frames.
std
::
vector
<
file
>
files
=
get_files_in_directory_tree
(
argv
[
1
],
match_ending
(
".jpg"
));
std
::
vector
<
file
>
files
=
get_files_in_directory_tree
(
argv
[
1
],
match_ending
(
".jpg"
));
std
::
sort
(
files
.
begin
(),
files
.
end
());
std
::
sort
(
files
.
begin
(),
files
.
end
());
if
(
files
.
size
()
==
0
)
if
(
files
.
size
()
==
0
)
...
@@ -34,12 +40,17 @@ int main(int argc, char** argv) try
...
@@ -34,12 +40,17 @@ int main(int argc, char** argv) try
return
1
;
return
1
;
}
}
// Load the first frame.
array2d
<
unsigned
char
>
img
;
array2d
<
unsigned
char
>
img
;
load_image
(
img
,
files
[
0
]);
load_image
(
img
,
files
[
0
]);
// Now create a tracker and start a track on the juice box. If you look at the first
// frame you will see that the juice box is centered at pixel point(92,110) and 38
// pixels wide and 86 pixels tall.
correlation_tracker
tracker
;
correlation_tracker
tracker
;
tracker
.
start_track
(
img
,
centered_rect
(
point
(
93
,
110
),
38
,
86
));
tracker
.
start_track
(
img
,
centered_rect
(
point
(
93
,
110
),
38
,
86
));
// Now run the tracker. All we have to do is call tracker.update() and it will keep
// track of the juice box!
image_window
win
;
image_window
win
;
for
(
unsigned
long
i
=
1
;
i
<
files
.
size
();
++
i
)
for
(
unsigned
long
i
=
1
;
i
<
files
.
size
();
++
i
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment