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
14a11a26
Commit
14a11a26
authored
Nov 15, 2013
by
Davis King
Browse files
Slightly simplified the code
parent
7742c575
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
38 deletions
+57
-38
dlib/image_processing/scan_fhog_pyramid.h
dlib/image_processing/scan_fhog_pyramid.h
+57
-38
No files found.
dlib/image_processing/scan_fhog_pyramid.h
View file @
14a11a26
...
@@ -299,6 +299,12 @@ namespace dlib
...
@@ -299,6 +299,12 @@ namespace dlib
typedef
array
<
array2d
<
float
>
>
fhog_image
;
typedef
array
<
array2d
<
float
>
>
fhog_image
;
static
rectangle
apply_filters_to_fhog
(
const
fhog_filterbank
&
w
,
const
fhog_image
&
feats
,
array2d
<
float
>&
saliency_image
);
array
<
fhog_image
>
feats
;
array
<
fhog_image
>
feats
;
int
cell_size
;
int
cell_size
;
unsigned
long
padding
;
unsigned
long
padding
;
...
@@ -311,6 +317,56 @@ namespace dlib
...
@@ -311,6 +317,56 @@ namespace dlib
};
};
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
rectangle
scan_fhog_pyramid
<
T
>::
apply_filters_to_fhog
(
const
fhog_filterbank
&
w
,
const
fhog_image
&
feats
,
array2d
<
float
>&
saliency_image
)
{
const
unsigned
long
num_separable_filters
=
w
.
num_separable_filters
();
rectangle
area
;
if
(
num_separable_filters
>
31
*
3
)
{
area
=
spatially_filter_image
(
feats
[
0
],
saliency_image
,
w
.
filters
[
0
]);
for
(
unsigned
long
i
=
1
;
i
<
w
.
filters
.
size
();
++
i
)
{
// now we filter but the output adds to saliency_image rather than
// overwriting it.
spatially_filter_image
(
feats
[
i
],
saliency_image
,
w
.
filters
[
i
],
1
,
false
,
true
);
}
}
else
{
saliency_image
.
clear
();
// find the first filter to apply
unsigned
long
i
=
0
;
while
(
i
<
w
.
row_filters
.
size
()
&&
w
.
row_filters
[
i
].
size
()
==
0
)
++
i
;
for
(;
i
<
w
.
row_filters
.
size
();
++
i
)
{
for
(
unsigned
long
j
=
0
;
j
<
w
.
row_filters
[
i
].
size
();
++
j
)
{
if
(
saliency_image
.
size
()
==
0
)
area
=
spatially_filter_image_separable
(
feats
[
i
],
saliency_image
,
w
.
row_filters
[
i
][
j
],
w
.
col_filters
[
i
][
j
],
1
,
false
,
false
);
else
area
=
spatially_filter_image_separable
(
feats
[
i
],
saliency_image
,
w
.
row_filters
[
i
][
j
],
w
.
col_filters
[
i
][
j
],
1
,
false
,
true
);
}
}
if
(
saliency_image
.
size
()
==
0
)
{
saliency_image
.
set_size
(
feats
[
0
].
nr
(),
feats
[
0
].
nc
());
assign_all_pixels
(
saliency_image
,
0
);
}
}
return
area
;
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
typename
T
>
template
<
typename
T
>
...
@@ -573,49 +629,12 @@ namespace dlib
...
@@ -573,49 +629,12 @@ namespace dlib
(
height
+
1
)
%
2
);
(
height
+
1
)
%
2
);
array2d
<
float
>
saliency_image
;
array2d
<
float
>
saliency_image
;
array2d
<
float
>
temp
;
pyramid_type
pyr
;
pyramid_type
pyr
;
const
unsigned
long
num_separable_filters
=
w
.
num_separable_filters
();
// for all pyramid levels
// for all pyramid levels
for
(
unsigned
long
l
=
0
;
l
<
feats
.
size
();
++
l
)
for
(
unsigned
long
l
=
0
;
l
<
feats
.
size
();
++
l
)
{
{
rectangle
area
;
const
rectangle
area
=
apply_filters_to_fhog
(
w
,
feats
[
l
],
saliency_image
);
if
(
num_separable_filters
>
31
*
3
)
{
area
=
spatially_filter_image
(
feats
[
l
][
0
],
saliency_image
,
w
.
filters
[
0
]);
for
(
unsigned
long
i
=
1
;
i
<
w
.
filters
.
size
();
++
i
)
{
// now we filter but the output adds to saliency_image rather than
// overwriting it.
spatially_filter_image
(
feats
[
l
][
i
],
saliency_image
,
w
.
filters
[
i
],
1
,
false
,
true
);
}
}
else
{
saliency_image
.
clear
();
// find the first filter to apply
unsigned
long
i
=
0
;
while
(
i
<
w
.
row_filters
.
size
()
&&
w
.
row_filters
[
i
].
size
()
==
0
)
++
i
;
for
(;
i
<
w
.
row_filters
.
size
();
++
i
)
{
for
(
unsigned
long
j
=
0
;
j
<
w
.
row_filters
[
i
].
size
();
++
j
)
{
if
(
saliency_image
.
size
()
==
0
)
area
=
spatially_filter_image_separable
(
feats
[
l
][
i
],
saliency_image
,
w
.
row_filters
[
i
][
j
],
w
.
col_filters
[
i
][
j
],
1
,
false
,
false
);
else
area
=
spatially_filter_image_separable
(
feats
[
l
][
i
],
saliency_image
,
w
.
row_filters
[
i
][
j
],
w
.
col_filters
[
i
][
j
],
1
,
false
,
true
);
}
}
if
(
saliency_image
.
size
()
==
0
)
{
saliency_image
.
set_size
(
feats
[
l
][
0
].
nr
(),
feats
[
l
][
0
].
nc
());
assign_all_pixels
(
saliency_image
,
0
);
}
}
// now search the saliency image for any detections
// now search the saliency image for any detections
for
(
long
r
=
area
.
top
();
r
<=
area
.
bottom
();
++
r
)
for
(
long
r
=
area
.
top
();
r
<=
area
.
bottom
();
++
r
)
...
...
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