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
dc778081
Commit
dc778081
authored
Jun 23, 2016
by
Davis King
Browse files
Options
Browse Files
Download
Plain Diff
merged
parents
247beb3d
b53e9cf0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
8 deletions
+16
-8
face_detector.py
python_examples/face_detector.py
+3
-1
object_detection.cpp
tools/python/src/object_detection.cpp
+2
-2
simple_object_detector_py.h
tools/python/src/simple_object_detector_py.h
+11
-5
No files found.
python_examples/face_detector.py
View file @
dc778081
...
...
@@ -71,11 +71,13 @@ for f in sys.argv[1:]:
# Finally, if you really want to you can ask the detector to tell you the score
# for each detection. The score is bigger for more confident detections.
# The third argument to run is an optional adjustment to the detection threshold,
# where a negative value will return more detections and a positive value fewer.
# Also, the idx tells you which of the face sub-detectors matched. This can be
# used to broadly identify faces in different orientations.
if
(
len
(
sys
.
argv
[
1
:])
>
0
):
img
=
io
.
imread
(
sys
.
argv
[
1
])
dets
,
scores
,
idx
=
detector
.
run
(
img
,
1
)
dets
,
scores
,
idx
=
detector
.
run
(
img
,
1
,
-
1
)
for
i
,
d
in
enumerate
(
dets
):
print
(
"Detection {}, score: {}, face_type:{}"
.
format
(
d
,
scores
[
i
],
idx
[
i
]))
...
...
tools/python/src/object_detection.cpp
View file @
dc778081
...
...
@@ -328,7 +328,7 @@ ensures \n\
detector. If you don't know how many times you want to upsample then
\n
\
don't provide a value for upsample_num_times and an appropriate
\n
\
default will be used."
)
.
def
(
"run"
,
run_rect_detector
,
(
arg
(
"image"
),
arg
(
"upsample_num_times"
)
=
0
),
.
def
(
"run"
,
run_rect_detector
,
(
arg
(
"image"
),
arg
(
"upsample_num_times"
)
=
0
,
arg
(
"adjust_threshold"
)
=
0.0
),
"requires
\n
\
- image is a numpy ndarray containing either an 8bit grayscale or RGB
\n
\
image.
\n
\
...
...
@@ -350,7 +350,7 @@ ensures \n\
.
def
(
"__init__"
,
make_constructor
(
&
load_object_from_file
<
type
>
),
"Loads a simple_object_detector from a file that contains the output of the
\n
\
train_simple_object_detector() routine."
)
.
def
(
"__call__"
,
&
type
::
run_detector1
,
(
arg
(
"image"
),
arg
(
"upsample_num_times"
)),
.
def
(
"__call__"
,
&
type
::
run_detector1
,
(
arg
(
"image"
),
arg
(
"upsample_num_times"
)
,
arg
(
"adjust_threshold"
)
=
0.0
),
"requires
\n
\
- image is a numpy ndarray containing either an 8bit grayscale or RGB
\n
\
image.
\n
\
...
...
tools/python/src/simple_object_detector_py.h
View file @
dc778081
...
...
@@ -37,6 +37,7 @@ namespace dlib
dlib
::
simple_object_detector
&
detector
,
boost
::
python
::
object
img
,
const
unsigned
int
upsampling_amount
,
const
double
adjust_threshold
,
std
::
vector
<
double
>&
detection_confidences
,
std
::
vector
<
double
>&
weight_indices
)
...
...
@@ -51,7 +52,7 @@ namespace dlib
array2d
<
unsigned
char
>
temp
;
if
(
upsampling_amount
==
0
)
{
detector
(
numpy_gray_image
(
img
),
rect_detections
,
0
.
0
);
detector
(
numpy_gray_image
(
img
),
rect_detections
,
adjust_threshold
);
split_rect_detections
(
rect_detections
,
rectangles
,
detection_confidences
,
weight_indices
);
return
rectangles
;
...
...
@@ -66,7 +67,7 @@ namespace dlib
pyramid_up
(
temp
);
}
detector
(
temp
,
rect_detections
,
0
.
0
);
detector
(
temp
,
rect_detections
,
adjust_threshold
);
for
(
unsigned
long
i
=
0
;
i
<
rect_detections
.
size
();
++
i
)
rect_detections
[
i
].
rect
=
pyr
.
rect_down
(
rect_detections
[
i
].
rect
,
upsampling_amount
);
...
...
@@ -81,7 +82,7 @@ namespace dlib
array2d
<
rgb_pixel
>
temp
;
if
(
upsampling_amount
==
0
)
{
detector
(
numpy_rgb_image
(
img
),
rect_detections
,
0
.
0
);
detector
(
numpy_rgb_image
(
img
),
rect_detections
,
adjust_threshold
);
split_rect_detections
(
rect_detections
,
rectangles
,
detection_confidences
,
weight_indices
);
return
rectangles
;
...
...
@@ -96,7 +97,7 @@ namespace dlib
pyramid_up
(
temp
);
}
detector
(
temp
,
rect_detections
,
0
.
0
);
detector
(
temp
,
rect_detections
,
adjust_threshold
);
for
(
unsigned
long
i
=
0
;
i
<
rect_detections
.
size
();
++
i
)
rect_detections
[
i
].
rect
=
pyr
.
rect_down
(
rect_detections
[
i
].
rect
,
upsampling_amount
);
...
...
@@ -116,19 +117,23 @@ namespace dlib
dlib
::
simple_object_detector
&
detector
,
boost
::
python
::
object
img
,
const
unsigned
int
upsampling_amount
)
{
std
::
vector
<
double
>
detection_confidences
;
std
::
vector
<
double
>
weight_indices
;
const
double
adjust_threshold
=
0
.
0
;
return
run_detector_with_upscale1
(
detector
,
img
,
upsampling_amount
,
adjust_threshold
,
detection_confidences
,
weight_indices
);
}
inline
boost
::
python
::
tuple
run_rect_detector
(
dlib
::
simple_object_detector
&
detector
,
boost
::
python
::
object
img
,
const
unsigned
int
upsampling_amount
)
const
unsigned
int
upsampling_amount
,
const
double
adjust_threshold
)
{
boost
::
python
::
tuple
t
;
...
...
@@ -137,6 +142,7 @@ namespace dlib
std
::
vector
<
rectangle
>
rectangles
;
rectangles
=
run_detector_with_upscale1
(
detector
,
img
,
upsampling_amount
,
adjust_threshold
,
detection_confidences
,
weight_indices
);
return
boost
::
python
::
make_tuple
(
rectangles
,
...
...
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