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
d50d8e02
Commit
d50d8e02
authored
Jun 18, 2018
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made the run_multiple() routine work identically for fhog and simple object detectors.
parent
19005f68
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
24 deletions
+42
-24
object_detection.cpp
tools/python/src/object_detection.cpp
+11
-0
simple_object_detector_py.h
tools/python/src/simple_object_detector_py.h
+31
-24
No files found.
tools/python/src/object_detection.cpp
View file @
d50d8e02
...
...
@@ -409,6 +409,17 @@ ensures \n\
a list of detections."
)
.
def
(
"save"
,
save_simple_object_detector_py
,
py
::
arg
(
"detector_output_filename"
),
"Save a simple_object_detector to the provided path."
)
.
def_readwrite
(
"upsampling_amount"
,
&
type
::
upsampling_amount
,
"The detector upsamples the image this many times before running."
)
.
def_static
(
"run_multiple"
,
run_multiple_rect_detectors
,
py
::
arg
(
"detectors"
),
py
::
arg
(
"image"
),
py
::
arg
(
"upsample_num_times"
)
=
0
,
py
::
arg
(
"adjust_threshold"
)
=
0.0
,
"requires
\n
\
- detectors is a list of detectors.
\n
\
- image is a numpy ndarray containing either an 8bit grayscale or RGB
\n
\
image.
\n
\
- upsample_num_times >= 0
\n
\
ensures
\n
\
- This function runs the list of object detectors at once on the input image and returns
\n
\
a tuple of (list of detections, list of scores, list of weight_indices).
\n
\
- Upsamples the image upsample_num_times before running the basic
\n
\
detector."
)
.
def
(
py
::
pickle
(
&
getstate
<
type
>
,
&
setstate
<
type
>
));
}
...
...
tools/python/src/simple_object_detector_py.h
View file @
d50d8e02
...
...
@@ -232,6 +232,29 @@ namespace dlib
vector_to_python_list
(
weight_indices
));
}
struct
simple_object_detector_py
{
simple_object_detector
detector
;
unsigned
int
upsampling_amount
;
simple_object_detector_py
()
{}
simple_object_detector_py
(
simple_object_detector
&
_detector
,
unsigned
int
_upsampling_amount
)
:
detector
(
_detector
),
upsampling_amount
(
_upsampling_amount
)
{}
std
::
vector
<
dlib
::
rectangle
>
run_detector1
(
py
::
array
img
,
const
unsigned
int
upsampling_amount_
)
{
return
run_detector_with_upscale2
(
detector
,
img
,
upsampling_amount_
);
}
std
::
vector
<
dlib
::
rectangle
>
run_detector2
(
py
::
array
img
)
{
return
run_detector_with_upscale2
(
detector
,
img
,
upsampling_amount
);
}
};
inline
py
::
tuple
run_multiple_rect_detectors
(
py
::
list
&
detectors
,
py
::
array
img
,
...
...
@@ -240,12 +263,18 @@ namespace dlib
{
py
::
tuple
t
;
std
::
vector
<
simple_object_detector
>
vector_detectors
;
std
::
vector
<
simple_object_detector
>
vector_detectors
;
const
unsigned
long
num_detectors
=
len
(
detectors
);
// Now copy the data into dlib based objects.
for
(
unsigned
long
i
=
0
;
i
<
num_detectors
;
++
i
)
{
vector_detectors
.
push_back
(
detectors
[
i
].
cast
<
simple_object_detector
>
());
try
{
vector_detectors
.
push_back
(
detectors
[
i
].
cast
<
simple_object_detector
>
());
}
catch
(
py
::
cast_error
&
)
{
vector_detectors
.
push_back
(
detectors
[
i
].
cast
<
simple_object_detector_py
>
().
detector
);
}
}
std
::
vector
<
double
>
detection_confidences
;
...
...
@@ -263,28 +292,6 @@ namespace dlib
struct
simple_object_detector_py
{
simple_object_detector
detector
;
unsigned
int
upsampling_amount
;
simple_object_detector_py
()
{}
simple_object_detector_py
(
simple_object_detector
&
_detector
,
unsigned
int
_upsampling_amount
)
:
detector
(
_detector
),
upsampling_amount
(
_upsampling_amount
)
{}
std
::
vector
<
dlib
::
rectangle
>
run_detector1
(
py
::
array
img
,
const
unsigned
int
upsampling_amount_
)
{
return
run_detector_with_upscale2
(
detector
,
img
,
upsampling_amount_
);
}
std
::
vector
<
dlib
::
rectangle
>
run_detector2
(
py
::
array
img
)
{
return
run_detector_with_upscale2
(
detector
,
img
,
upsampling_amount
);
}
};
}
#endif // DLIB_SIMPLE_OBJECT_DETECTOR_PY_H__
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