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
06dc489c
Commit
06dc489c
authored
Dec 26, 2011
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some more tests and also fixed the existing ones to work
given the recent changes to the object detection tools.
parent
c2ad9698
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
6 deletions
+45
-6
object_detector.cpp
dlib/test/object_detector.cpp
+45
-6
No files found.
dlib/test/object_detector.cpp
View file @
06dc489c
...
...
@@ -2,6 +2,7 @@
// License: Boost Software License See LICENSE.txt for the full license.
#include <dlib/statistics.h>
#include <sstream>
#include <string>
#include <cstdlib>
...
...
@@ -37,6 +38,42 @@ namespace
a
.
img
.
swap
(
b
.
img
);
}
// ----------------------------------------------------------------------------------------
template
<
typename
image_array_type
,
typename
detector_type
>
void
validate_some_object_detector_stuff
(
const
image_array_type
&
images
,
detector_type
&
detector
)
{
for
(
unsigned
long
i
=
0
;
i
<
images
.
size
();
++
i
)
{
std
::
vector
<
rectangle
>
dets
=
detector
(
images
[
i
]);
std
::
vector
<
std
::
pair
<
double
,
rectangle
>
>
dets2
;
detector
(
images
[
i
],
dets2
);
matrix
<
double
,
0
,
1
>
psi
(
detector
.
get_w
().
size
());
const
double
thresh
=
detector
.
get_w
()(
detector
.
get_w
().
size
()
-
1
);
DLIB_TEST
(
dets
.
size
()
==
dets2
.
size
());
for
(
unsigned
long
j
=
0
;
j
<
dets
.
size
();
++
j
)
{
DLIB_TEST
(
dets
[
j
]
==
dets2
[
j
].
second
);
psi
=
0
;
detector
.
get_scanner
().
get_feature_vector
(
dets
[
j
],
psi
);
const
double
check_score
=
dot
(
psi
,
detector
.
get_w
())
-
thresh
;
DLIB_TEST
(
std
::
abs
(
check_score
-
dets2
[
j
].
first
)
<
1e-10
);
}
}
}
// ----------------------------------------------------------------------------------------
class
very_simple_feature_extractor
:
noncopyable
...
...
@@ -229,10 +266,11 @@ namespace
image_scanner_type
scanner
;
const
rectangle
object_box
=
compute_box_dimensions
(
1
,
35
*
35
);
scanner
.
add_detection_template
(
object_box
,
create_grid_detection_template
(
object_box
,
2
,
2
));
setup_hashed_features
(
scanner
,
images
,
9
);
structural_object_detection_trainer
<
image_scanner_type
>
trainer
(
scanner
);
trainer
.
set_num_threads
(
4
);
trainer
.
set_overlap_tester
(
test_box_overlap
(
0
));
const
object_detector
<
image_scanner_type
>
detector
=
trainer
.
train
(
images
,
object_locations
);
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
;
...
...
@@ -247,6 +285,8 @@ namespace
matrix
<
double
>
res
=
test_object_detection_function
(
detector
,
images
,
object_locations
);
dlog
<<
LINFO
<<
"Test detector (precision,recall): "
<<
res
;
DLIB_TEST
(
sum
(
res
)
==
2
);
validate_some_object_detector_stuff
(
images
,
detector
);
}
}
...
...
@@ -270,8 +310,7 @@ namespace
scanner
.
set_max_pyramid_levels
(
1
);
structural_object_detection_trainer
<
image_scanner_type
>
trainer
(
scanner
);
trainer
.
set_num_threads
(
0
);
trainer
.
set_overlap_tester
(
test_box_overlap
(
0
));
const
object_detector
<
image_scanner_type
>
detector
=
trainer
.
train
(
images
,
object_locations
);
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
;
...
...
@@ -290,6 +329,7 @@ namespace
matrix
<
double
>
res
=
test_object_detection_function
(
detector
,
images
,
object_locations
);
dlog
<<
LINFO
<<
"Test detector (precision,recall): "
<<
res
;
DLIB_TEST
(
sum
(
res
)
==
2
);
validate_some_object_detector_stuff
(
images
,
detector
);
}
}
...
...
@@ -362,8 +402,7 @@ namespace
scanner
.
set_max_pyramid_levels
(
1
);
structural_object_detection_trainer
<
image_scanner_type
>
trainer
(
scanner
);
trainer
.
set_num_threads
(
4
);
trainer
.
set_overlap_tester
(
test_box_overlap
(
0
));
const
object_detector
<
image_scanner_type
>
detector
=
trainer
.
train
(
images
,
object_locations
);
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
;
...
...
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