Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
0bdcb98c
Commit
0bdcb98c
authored
Oct 04, 2013
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a bug in extract_fhog_features() that happened when very small
images were given.
parent
e0a6e305
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
fhog.h
dlib/image_transforms/fhog.h
+11
-0
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