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
dc778081
"git@developer.sourcefind.cn:OpenDAS/megatron-lm.git" did not exist on "613d0fe8bd3be77680595767f7ec36163991fc0f"
Commit
dc778081
authored
Jun 22, 2016
by
Davis King
Browse files
merged
parents
247beb3d
b53e9cf0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
8 deletions
+16
-8
python_examples/face_detector.py
python_examples/face_detector.py
+3
-1
tools/python/src/object_detection.cpp
tools/python/src/object_detection.cpp
+2
-2
tools/python/src/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:]:
...
@@ -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
# 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.
# 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
# Also, the idx tells you which of the face sub-detectors matched. This can be
# used to broadly identify faces in different orientations.
# used to broadly identify faces in different orientations.
if
(
len
(
sys
.
argv
[
1
:])
>
0
):
if
(
len
(
sys
.
argv
[
1
:])
>
0
):
img
=
io
.
imread
(
sys
.
argv
[
1
])
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
):
for
i
,
d
in
enumerate
(
dets
):
print
(
"Detection {}, score: {}, face_type:{}"
.
format
(
print
(
"Detection {}, score: {}, face_type:{}"
.
format
(
d
,
scores
[
i
],
idx
[
i
]))
d
,
scores
[
i
],
idx
[
i
]))
...
...
tools/python/src/object_detection.cpp
View file @
dc778081
...
@@ -328,7 +328,7 @@ ensures \n\
...
@@ -328,7 +328,7 @@ ensures \n\
detector. If you don't know how many times you want to upsample then
\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
\
don't provide a value for upsample_num_times and an appropriate
\n
\
default will be used."
)
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
\
"requires
\n
\
- image is a numpy ndarray containing either an 8bit grayscale or RGB
\n
\
- image is a numpy ndarray containing either an 8bit grayscale or RGB
\n
\
image.
\n
\
image.
\n
\
...
@@ -350,7 +350,7 @@ ensures \n\
...
@@ -350,7 +350,7 @@ ensures \n\
.
def
(
"__init__"
,
make_constructor
(
&
load_object_from_file
<
type
>
),
.
def
(
"__init__"
,
make_constructor
(
&
load_object_from_file
<
type
>
),
"Loads a simple_object_detector from a file that contains the output of the
\n
\
"Loads a simple_object_detector from a file that contains the output of the
\n
\
train_simple_object_detector() routine."
)
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
\
"requires
\n
\
- image is a numpy ndarray containing either an 8bit grayscale or RGB
\n
\
- image is a numpy ndarray containing either an 8bit grayscale or RGB
\n
\
image.
\n
\
image.
\n
\
...
...
tools/python/src/simple_object_detector_py.h
View file @
dc778081
...
@@ -37,6 +37,7 @@ namespace dlib
...
@@ -37,6 +37,7 @@ namespace dlib
dlib
::
simple_object_detector
&
detector
,
dlib
::
simple_object_detector
&
detector
,
boost
::
python
::
object
img
,
boost
::
python
::
object
img
,
const
unsigned
int
upsampling_amount
,
const
unsigned
int
upsampling_amount
,
const
double
adjust_threshold
,
std
::
vector
<
double
>&
detection_confidences
,
std
::
vector
<
double
>&
detection_confidences
,
std
::
vector
<
double
>&
weight_indices
std
::
vector
<
double
>&
weight_indices
)
)
...
@@ -51,7 +52,7 @@ namespace dlib
...
@@ -51,7 +52,7 @@ namespace dlib
array2d
<
unsigned
char
>
temp
;
array2d
<
unsigned
char
>
temp
;
if
(
upsampling_amount
==
0
)
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
,
split_rect_detections
(
rect_detections
,
rectangles
,
detection_confidences
,
weight_indices
);
detection_confidences
,
weight_indices
);
return
rectangles
;
return
rectangles
;
...
@@ -66,7 +67,7 @@ namespace dlib
...
@@ -66,7 +67,7 @@ namespace dlib
pyramid_up
(
temp
);
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
)
for
(
unsigned
long
i
=
0
;
i
<
rect_detections
.
size
();
++
i
)
rect_detections
[
i
].
rect
=
pyr
.
rect_down
(
rect_detections
[
i
].
rect
,
rect_detections
[
i
].
rect
=
pyr
.
rect_down
(
rect_detections
[
i
].
rect
,
upsampling_amount
);
upsampling_amount
);
...
@@ -81,7 +82,7 @@ namespace dlib
...
@@ -81,7 +82,7 @@ namespace dlib
array2d
<
rgb_pixel
>
temp
;
array2d
<
rgb_pixel
>
temp
;
if
(
upsampling_amount
==
0
)
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
,
split_rect_detections
(
rect_detections
,
rectangles
,
detection_confidences
,
weight_indices
);
detection_confidences
,
weight_indices
);
return
rectangles
;
return
rectangles
;
...
@@ -96,7 +97,7 @@ namespace dlib
...
@@ -96,7 +97,7 @@ namespace dlib
pyramid_up
(
temp
);
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
)
for
(
unsigned
long
i
=
0
;
i
<
rect_detections
.
size
();
++
i
)
rect_detections
[
i
].
rect
=
pyr
.
rect_down
(
rect_detections
[
i
].
rect
,
rect_detections
[
i
].
rect
=
pyr
.
rect_down
(
rect_detections
[
i
].
rect
,
upsampling_amount
);
upsampling_amount
);
...
@@ -116,19 +117,23 @@ namespace dlib
...
@@ -116,19 +117,23 @@ namespace dlib
dlib
::
simple_object_detector
&
detector
,
dlib
::
simple_object_detector
&
detector
,
boost
::
python
::
object
img
,
boost
::
python
::
object
img
,
const
unsigned
int
upsampling_amount
const
unsigned
int
upsampling_amount
)
)
{
{
std
::
vector
<
double
>
detection_confidences
;
std
::
vector
<
double
>
detection_confidences
;
std
::
vector
<
double
>
weight_indices
;
std
::
vector
<
double
>
weight_indices
;
const
double
adjust_threshold
=
0.0
;
return
run_detector_with_upscale1
(
detector
,
img
,
upsampling_amount
,
return
run_detector_with_upscale1
(
detector
,
img
,
upsampling_amount
,
adjust_threshold
,
detection_confidences
,
weight_indices
);
detection_confidences
,
weight_indices
);
}
}
inline
boost
::
python
::
tuple
run_rect_detector
(
inline
boost
::
python
::
tuple
run_rect_detector
(
dlib
::
simple_object_detector
&
detector
,
dlib
::
simple_object_detector
&
detector
,
boost
::
python
::
object
img
,
boost
::
python
::
object
img
,
const
unsigned
int
upsampling_amount
)
const
unsigned
int
upsampling_amount
,
const
double
adjust_threshold
)
{
{
boost
::
python
::
tuple
t
;
boost
::
python
::
tuple
t
;
...
@@ -137,6 +142,7 @@ namespace dlib
...
@@ -137,6 +142,7 @@ namespace dlib
std
::
vector
<
rectangle
>
rectangles
;
std
::
vector
<
rectangle
>
rectangles
;
rectangles
=
run_detector_with_upscale1
(
detector
,
img
,
upsampling_amount
,
rectangles
=
run_detector_with_upscale1
(
detector
,
img
,
upsampling_amount
,
adjust_threshold
,
detection_confidences
,
weight_indices
);
detection_confidences
,
weight_indices
);
return
boost
::
python
::
make_tuple
(
rectangles
,
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