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
17a46669
"examples/vscode:/vscode.git/clone" did not exist on "a9768cb38fc21480bc4079c7d02bd611290da71d"
Commit
17a46669
authored
Nov 17, 2013
by
Davis King
Browse files
Added unit tests for new scan_fhog_pyramid object.
parent
46bb6dc8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
2 deletions
+44
-2
dlib/test/object_detector.cpp
dlib/test/object_detector.cpp
+44
-2
No files found.
dlib/test/object_detector.cpp
View file @
17a46669
...
@@ -46,7 +46,8 @@ namespace
...
@@ -46,7 +46,8 @@ namespace
>
>
void
validate_some_object_detector_stuff
(
void
validate_some_object_detector_stuff
(
const
image_array_type
&
images
,
const
image_array_type
&
images
,
detector_type
&
detector
detector_type
&
detector
,
double
eps
=
1e-10
)
)
{
{
for
(
unsigned
long
i
=
0
;
i
<
images
.
size
();
++
i
)
for
(
unsigned
long
i
=
0
;
i
<
images
.
size
();
++
i
)
...
@@ -70,7 +71,7 @@ namespace
...
@@ -70,7 +71,7 @@ namespace
detector
.
get_scanner
().
get_feature_vector
(
fdet
,
psi
);
detector
.
get_scanner
().
get_feature_vector
(
fdet
,
psi
);
double
check_score
=
dot
(
psi
,
detector
.
get_w
())
-
thresh
;
double
check_score
=
dot
(
psi
,
detector
.
get_w
())
-
thresh
;
DLIB_TEST
(
std
::
abs
(
check_score
-
dets2
[
j
].
first
)
<
1e-10
);
DLIB_TEST
_MSG
(
std
::
abs
(
check_score
-
dets2
[
j
].
first
)
<
eps
,
std
::
abs
(
check_score
-
dets2
[
j
].
first
)
<<
" check_score: "
<<
check_score
);
}
}
}
}
...
@@ -365,6 +366,46 @@ namespace
...
@@ -365,6 +366,46 @@ namespace
}
}
}
}
}
}
// ----------------------------------------------------------------------------------------
void
test_fhog_pyramid
(
)
{
print_spinner
();
dlog
<<
LINFO
<<
"test_fhog_pyramid()"
;
typedef
dlib
::
array
<
array2d
<
unsigned
char
>
>
grayscale_image_array_type
;
grayscale_image_array_type
images
;
std
::
vector
<
std
::
vector
<
rectangle
>
>
object_locations
;
make_simple_test_data
(
images
,
object_locations
);
typedef
scan_fhog_pyramid
<
pyramid_down
<
2
>
>
image_scanner_type
;
image_scanner_type
scanner
;
scanner
.
set_detection_window_size
(
35
,
35
);
structural_object_detection_trainer
<
image_scanner_type
>
trainer
(
scanner
);
trainer
.
set_num_threads
(
4
);
trainer
.
set_overlap_tester
(
test_box_overlap
(
0
,
0
));
object_detector
<
image_scanner_type
>
detector
=
trainer
.
train
(
images
,
object_locations
);
matrix
<
double
>
res
=
test_object_detection_function
(
detector
,
images
,
object_locations
);
dlog
<<
LINFO
<<
"Test detector (precision,recall): "
<<
res
;
DLIB_TEST
(
sum
(
res
)
==
3
);
{
ostringstream
sout
;
serialize
(
detector
,
sout
);
istringstream
sin
(
sout
.
str
());
object_detector
<
image_scanner_type
>
d2
;
deserialize
(
d2
,
sin
);
matrix
<
double
>
res
=
test_object_detection_function
(
d2
,
images
,
object_locations
);
dlog
<<
LINFO
<<
"Test detector (precision,recall): "
<<
res
;
DLIB_TEST
(
sum
(
res
)
==
3
);
validate_some_object_detector_stuff
(
images
,
detector
,
1e-6
);
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
void
test_1
(
void
test_1
(
...
@@ -940,6 +981,7 @@ namespace
...
@@ -940,6 +981,7 @@ namespace
void
perform_test
(
void
perform_test
(
)
)
{
{
test_fhog_pyramid
();
test_1_boxes
();
test_1_boxes
();
test_1_poly_nn_boxes
();
test_1_poly_nn_boxes
();
test_3_boxes
();
test_3_boxes
();
...
...
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