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
0bdcb98c
Commit
0bdcb98c
authored
Oct 03, 2013
by
Davis King
Browse files
Fixed a bug in extract_fhog_features() that happened when very small
images were given.
parent
e0a6e305
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
dlib/image_transforms/fhog.h
dlib/image_transforms/fhog.h
+11
-0
dlib/test/fhog.cpp
dlib/test/fhog.cpp
+29
-0
No files found.
dlib/image_transforms/fhog.h
View file @
0bdcb98c
...
@@ -193,6 +193,12 @@ namespace dlib
...
@@ -193,6 +193,12 @@ namespace dlib
const
int
cells_nr
=
(
int
)((
double
)
img
.
nr
()
/
(
double
)
cell_size
+
0.5
);
const
int
cells_nr
=
(
int
)((
double
)
img
.
nr
()
/
(
double
)
cell_size
+
0.5
);
const
int
cells_nc
=
(
int
)((
double
)
img
.
nc
()
/
(
double
)
cell_size
+
0.5
);
const
int
cells_nc
=
(
int
)((
double
)
img
.
nc
()
/
(
double
)
cell_size
+
0.5
);
if
(
cells_nr
==
0
||
cells_nc
==
0
)
{
hog
.
clear
();
return
;
}
array2d
<
matrix
<
float
,
18
,
1
>
>
hist
(
cells_nr
,
cells_nc
);
array2d
<
matrix
<
float
,
18
,
1
>
>
hist
(
cells_nr
,
cells_nc
);
for
(
long
r
=
0
;
r
<
hist
.
nr
();
++
r
)
for
(
long
r
=
0
;
r
<
hist
.
nr
();
++
r
)
{
{
...
@@ -208,6 +214,11 @@ namespace dlib
...
@@ -208,6 +214,11 @@ namespace dlib
// memory for HOG features
// memory for HOG features
const
int
hog_nr
=
std
::
max
(
cells_nr
-
2
,
0
);
const
int
hog_nr
=
std
::
max
(
cells_nr
-
2
,
0
);
const
int
hog_nc
=
std
::
max
(
cells_nc
-
2
,
0
);
const
int
hog_nc
=
std
::
max
(
cells_nc
-
2
,
0
);
if
(
hog_nr
==
0
||
hog_nc
==
0
)
{
hog
.
clear
();
return
;
}
init_hog
(
hog
,
hog_nr
,
hog_nc
);
init_hog
(
hog
,
hog_nr
,
hog_nc
);
const
int
visible_nr
=
cells_nr
*
cell_size
;
const
int
visible_nr
=
cells_nr
*
cell_size
;
...
...
dlib/test/fhog.cpp
View file @
0bdcb98c
...
@@ -76,9 +76,38 @@ namespace
...
@@ -76,9 +76,38 @@ namespace
}
}
}
}
void
test_on_small
()
{
print_spinner
();
array2d
<
unsigned
char
>
img
;
dlib
::
array
<
array2d
<
float
>
>
hog
;
// do this just to make sure it doesn't crash on small images
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
img
.
set_size
(
i
,
i
);
assign_all_pixels
(
img
,
i
);
extract_fhog_features
(
img
,
hog
);
}
for
(
int
i
=
1
;
i
<
10
;
++
i
)
{
img
.
set_size
(
i
,
i
+
1
);
assign_all_pixels
(
img
,
i
);
extract_fhog_features
(
img
,
hog
);
}
for
(
int
i
=
1
;
i
<
10
;
++
i
)
{
img
.
set_size
(
i
+
1
,
i
);
assign_all_pixels
(
img
,
i
);
extract_fhog_features
(
img
,
hog
);
}
}
void
perform_test
(
void
perform_test
(
)
)
{
{
test_on_small
();
print_spinner
();
print_spinner
();
// load the testing data
// load the testing data
array2d
<
rgb_pixel
>
img
;
array2d
<
rgb_pixel
>
img
;
...
...
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