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
6e9ee89e
Commit
6e9ee89e
authored
Apr 08, 2016
by
Davis King
Browse files
merged
parents
fe168596
eb25bf44
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
114 additions
and
25 deletions
+114
-25
dlib/image_processing/correlation_tracker.h
dlib/image_processing/correlation_tracker.h
+52
-17
dlib/image_processing/correlation_tracker_abstract.h
dlib/image_processing/correlation_tracker_abstract.h
+55
-1
dlib/test/CMakeLists.txt
dlib/test/CMakeLists.txt
+1
-1
dlib/test/correlation_tracker.cpp
dlib/test/correlation_tracker.cpp
+6
-6
No files found.
dlib/image_processing/correlation_tracker.h
View file @
6e9ee89e
...
...
@@ -19,8 +19,20 @@ namespace dlib
{
public:
correlation_tracker
(
explicit
correlation_tracker
(
unsigned
long
filter_size
=
6
,
unsigned
long
num_scale_levels
=
5
,
unsigned
long
scale_window_size
=
23
,
double
regularizer_space
=
0.001
,
double
nu_space
=
0.025
,
double
regularizer_scale
=
0.001
,
double
nu_scale
=
0.025
,
double
scale_pyramid_alpha
=
1.020
)
:
filter_size
(
1
<<
filter_size
),
num_scale_levels
(
1
<<
num_scale_levels
),
scale_window_size
(
scale_window_size
),
regularizer_space
(
regularizer_space
),
nu_space
(
nu_space
),
regularizer_scale
(
regularizer_scale
),
nu_scale
(
nu_scale
),
scale_pyramid_alpha
(
scale_pyramid_alpha
)
{
// Create the cosine mask used for space filtering.
mask
=
make_cosine_mask
();
...
...
@@ -78,23 +90,23 @@ namespace dlib
unsigned
long
get_filter_size
(
)
const
{
return
128
/
2
;
}
// must be power of 2
)
const
{
return
filter_size
;
}
unsigned
long
get_num_scale_levels
(
)
const
{
return
32
;
}
// must be power of 2
)
const
{
return
num_scale_levels
;
}
unsigned
long
get_scale_window_size
(
)
const
{
return
23
;
}
)
const
{
return
scale_window_size
;
}
double
get_regularizer_space
(
)
const
{
return
0.001
;
}
)
const
{
return
regularizer_space
;
}
inline
double
get_nu_space
(
)
const
{
return
0.025
;}
)
const
{
return
nu_space
;}
double
get_regularizer_scale
(
)
const
{
return
0.001
;
}
)
const
{
return
regularizer_scale
;
}
double
get_nu_scale
(
)
const
{
return
0.025
;}
)
const
{
return
nu_scale
;}
drectangle
get_position
(
)
const
...
...
@@ -103,13 +115,11 @@ namespace dlib
}
double
get_scale_pyramid_alpha
(
)
const
{
return
1.020
;
}
)
const
{
return
scale_pyramid_alpha
;
}
template
<
typename
image_type
>
double
update
(
double
update
_noscale
(
const
image_type
&
img
,
const
drectangle
&
guess
)
...
...
@@ -125,7 +135,7 @@ namespace dlib
fft_inplace
(
F
[
i
]);
// use the current filter to predict the object's location
G
=
0
;
G
=
0
;
for
(
unsigned
long
i
=
0
;
i
<
F
.
size
();
++
i
)
G
+=
pointwise_multiply
(
F
[
i
],
conj
(
A
[
i
]));
G
=
pointwise_multiply
(
G
,
reciprocal
(
B
+
get_regularizer_space
()));
...
...
@@ -147,9 +157,8 @@ namespace dlib
}
const
double
psr
=
(
G
(
p
.
y
(),
p
.
x
()).
real
()
-
rs
.
mean
())
/
rs
.
stddev
();
// update the position of the object
position
=
translate_rect
(
guess
,
tform
(
pp
)
-
center
(
guess
));
position
=
translate_rect
(
guess
,
tform
(
pp
)
-
center
(
guess
));
// now update the position filters
make_target_location_image
(
pp
,
G
);
...
...
@@ -160,7 +169,16 @@ namespace dlib
B
+=
get_nu_space
()
*
(
squared
(
real
(
F
[
i
]))
+
squared
(
imag
(
F
[
i
])));
}
return
psr
;
}
template
<
typename
image_type
>
double
update
(
const
image_type
&
img
,
const
drectangle
&
guess
)
{
double
psr
=
update_noscale
(
img
,
guess
);
// Now predict the scale change
make_scale_space
(
img
,
Fs
);
...
...
@@ -192,9 +210,17 @@ namespace dlib
}
template
<
typename
image_type
>
double
update
(
double
update
_noscale
(
const
image_type
&
img
)
{
return
update_noscale
(
img
,
get_position
());
}
template
<
typename
image_type
>
double
update
(
const
image_type
&
img
)
{
return
update
(
img
,
get_position
());
}
...
...
@@ -361,6 +387,15 @@ namespace dlib
// here just so we can void reallocating them over and over.
matrix
<
std
::
complex
<
double
>
>
G
;
matrix
<
std
::
complex
<
double
>
,
0
,
1
>
Gs
;
unsigned
long
filter_size
;
unsigned
long
num_scale_levels
;
unsigned
long
scale_window_size
;
double
regularizer_space
;
double
nu_space
;
double
regularizer_scale
;
double
nu_scale
;
double
scale_pyramid_alpha
;
};
}
...
...
dlib/image_processing/correlation_tracker_abstract.h
View file @
6e9ee89e
...
...
@@ -25,10 +25,23 @@ namespace dlib
public:
correlation_tracker
(
explicit
correlation_tracker
(
unsigned
long
filter_size
=
6
,
unsigned
long
num_scale_levels
=
5
,
unsigned
long
scale_window_size
=
23
,
double
regularizer_space
=
0.001
,
double
nu_space
=
0.025
,
double
regularizer_scale
=
0.001
,
double
nu_scale
=
0.025
,
double
scale_pyramid_alpha
=
1.020
);
/*!
requires
- p.is_empty() == false
ensures
- Initializes correlation_tracker. Higher value of filter_size and
num_scale_levels increases tracking precision but requires more CPU
for processing. Recommended values for filter_size = 5-7,
default = 6, for num_scale_levels = 4-6, default = 5
- #get_position().is_empty() == true
!*/
...
...
@@ -58,6 +71,32 @@ namespace dlib
- returns the predicted position of the object under track.
!*/
template
<
typename
image_type
>
double
update_noscale
(
const
image_type
&
img
,
const
drectangle
&
guess
);
/*!
requires
- image_type == an image object that implements the interface defined in
dlib/image_processing/generic_image.h
- get_position().is_empty() == false
(i.e. you must have started tracking by calling start_track())
ensures
- When searching for the object in img, we search in the area around the
provided guess. This function only tracks object position without trying
to track the scale
- #get_position() == the new predicted location of the object in img. This
location will be a copy of guess that has been translated and NOT scaled
appropriately based on the content of img so that it, hopefully, bounds
the object in img.
- Returns the peak to side-lobe ratio. This is a number that measures how
confident the tracker is that the object is inside #get_position().
Larger values indicate higher confidence.
!*/
template
<
typename
image_type
>
...
...
@@ -83,6 +122,21 @@ namespace dlib
Larger values indicate higher confidence.
!*/
template
<
typename
image_type
>
double
update_noscale
(
const
image_type
&
img
);
/*!
requires
- image_type == an image object that implements the interface defined in
dlib/image_processing/generic_image.h
- get_position().is_empty() == false
(i.e. you must have started tracking by calling start_track())
ensures
- performs: return update_noscale(img, get_position())
!*/
template
<
typename
image_type
>
...
...
dlib/test/CMakeLists.txt
View file @
6e9ee89e
...
...
@@ -39,7 +39,7 @@ set (tests
conditioning_class_c.cpp
conditioning_class.cpp
config_reader.cpp
core
l
lation_tracker.cpp
cor
r
elation_tracker.cpp
crc32.cpp
create_iris_datafile.cpp
data_io.cpp
...
...
dlib/test/core
l
lation_tracker.cpp
→
dlib/test/cor
r
elation_tracker.cpp
View file @
6e9ee89e
...
...
@@ -14,17 +14,17 @@ namespace
using
namespace
test
;
using
namespace
dlib
;
using
namespace
std
;
dlib
::
logger
dlog
(
"test.core
l
lation_tracker"
);
dlib
::
logger
dlog
(
"test.cor
r
elation_tracker"
);
class
core
l
lation_tracker_tester
:
public
tester
class
cor
r
elation_tracker_tester
:
public
tester
{
public:
core
l
lation_tracker_tester
(
cor
r
elation_tracker_tester
(
)
:
tester
(
"test_core
l
lation_tracker"
,
// the command line argument name for this test
"Run tests on the core
l
lation_tracker functions."
,
// the command line argument description
"test_cor
r
elation_tracker"
,
// the command line argument name for this test
"Run tests on the cor
r
elation_tracker functions."
,
// the command line argument description
0
// the number of command line arguments for this test
)
{
...
...
@@ -946,7 +946,7 @@ namespace
};
core
l
lation_tracker_tester
a
;
cor
r
elation_tracker_tester
a
;
// ----------------------------------------------------------------------------------------
...
...
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