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
9b78932a
Commit
9b78932a
authored
Mar 12, 2015
by
Jack Culpepper
Browse files
re-arrange, use vector<double> to facilitate pass back to python
parent
154f9e49
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
31 deletions
+34
-31
tools/python/src/object_detection.cpp
tools/python/src/object_detection.cpp
+12
-12
tools/python/src/simple_object_detector_py.h
tools/python/src/simple_object_detector_py.h
+22
-19
No files found.
tools/python/src/object_detection.cpp
View file @
9b78932a
...
@@ -350,6 +350,18 @@ object_detector<scan_fhog_pyramid<pyramid_down<6>>>.")
...
@@ -350,6 +350,18 @@ object_detector<scan_fhog_pyramid<pyramid_down<6>>>.")
ensures
\n
\
ensures
\n
\
- This function runs the object detector on the input image and returns
\n
\
- This function runs the object detector on the input image and returns
\n
\
a list of detections.
\n
\
a list of detections.
\n
\
- Upsamples the image upsample_num_times before running the basic
\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"
)),
"requires
\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 object detector 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
\
- Upsamples the image upsample_num_times before running the basic
\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
\
...
@@ -383,18 +395,6 @@ ensures \n\
...
@@ -383,18 +395,6 @@ ensures \n\
ensures
\n
\
ensures
\n
\
- This function runs the object detector on the input image and returns
\n
\
- This function runs the object detector on the input image and returns
\n
\
a list of detections."
)
a list of detections."
)
.
def
(
"run"
,
&
type
::
run_detector3
,
(
arg
(
"image"
),
arg
(
"upsample_num_times"
)),
"requires
\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 object detector 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. 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
(
"save"
,
save_simple_object_detector_py
,
(
arg
(
"detector_output_filename"
)),
"Save a simple_object_detector to the provided path."
)
.
def
(
"save"
,
save_simple_object_detector_py
,
(
arg
(
"detector_output_filename"
)),
"Save a simple_object_detector to the provided path."
)
.
def_pickle
(
serialize_pickle
<
type
>
());
.
def_pickle
(
serialize_pickle
<
type
>
());
}
}
...
...
tools/python/src/simple_object_detector_py.h
View file @
9b78932a
...
@@ -17,7 +17,7 @@ namespace dlib
...
@@ -17,7 +17,7 @@ namespace dlib
std
::
vector
<
rect_detection
>&
rect_detections
,
std
::
vector
<
rect_detection
>&
rect_detections
,
std
::
vector
<
rectangle
>&
rectangles
,
std
::
vector
<
rectangle
>&
rectangles
,
std
::
vector
<
double
>&
detection_confidences
,
std
::
vector
<
double
>&
detection_confidences
,
std
::
vector
<
int
>&
weight_indices
std
::
vector
<
double
>&
weight_indices
)
)
{
{
rectangles
.
clear
();
rectangles
.
clear
();
...
@@ -37,7 +37,7 @@ namespace dlib
...
@@ -37,7 +37,7 @@ namespace dlib
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
<
int
>&
weight_indices
std
::
vector
<
double
>&
weight_indices
)
)
{
{
pyramid_down
<
2
>
pyr
;
pyramid_down
<
2
>
pyr
;
...
@@ -111,6 +111,24 @@ namespace dlib
...
@@ -111,6 +111,24 @@ namespace dlib
}
}
}
}
inline
boost
::
python
::
tuple
run_rect_detector
(
dlib
::
simple_object_detector
&
detector
,
boost
::
python
::
object
img
,
const
unsigned
int
upsampling_amount
)
{
boost
::
python
::
tuple
t
;
std
::
vector
<
double
>
detection_confidences
;
std
::
vector
<
double
>
weight_indices
;
std
::
vector
<
rectangle
>
rectangles
;
rectangles
=
run_detector_with_upscale
(
detector
,
img
,
upsampling_amount
,
detection_confidences
,
weight_indices
);
return
boost
::
python
::
make_tuple
(
rectangles
,
detection_confidences
,
weight_indices
);
}
struct
simple_object_detector_py
struct
simple_object_detector_py
{
{
simple_object_detector
detector
;
simple_object_detector
detector
;
...
@@ -124,7 +142,7 @@ namespace dlib
...
@@ -124,7 +142,7 @@ namespace dlib
const
unsigned
int
upsampling_amount_
)
const
unsigned
int
upsampling_amount_
)
{
{
std
::
vector
<
double
>
detection_confidences
;
std
::
vector
<
double
>
detection_confidences
;
std
::
vector
<
int
>
weight_indices
;
std
::
vector
<
double
>
weight_indices
;
return
run_detector_with_upscale
(
detector
,
img
,
upsampling_amount_
,
return
run_detector_with_upscale
(
detector
,
img
,
upsampling_amount_
,
detection_confidences
,
weight_indices
);
detection_confidences
,
weight_indices
);
...
@@ -133,27 +151,12 @@ namespace dlib
...
@@ -133,27 +151,12 @@ namespace dlib
std
::
vector
<
dlib
::
rectangle
>
run_detector2
(
boost
::
python
::
object
img
)
std
::
vector
<
dlib
::
rectangle
>
run_detector2
(
boost
::
python
::
object
img
)
{
{
std
::
vector
<
double
>
detection_confidences
;
std
::
vector
<
double
>
detection_confidences
;
std
::
vector
<
int
>
weight_indices
;
std
::
vector
<
double
>
weight_indices
;
return
run_detector_with_upscale
(
detector
,
img
,
upsampling_amount
,
return
run_detector_with_upscale
(
detector
,
img
,
upsampling_amount
,
detection_confidences
,
weight_indices
);
detection_confidences
,
weight_indices
);
}
}
boost
::
python
::
tuple
run_detector3
(
boost
::
python
::
object
img
,
const
unsigned
int
upsampling_amount_
)
{
boost
::
python
::
tuple
t
;
std
::
vector
<
double
>
detection_confidences
;
std
::
vector
<
int
>
weight_indices
;
std
::
vector
<
rectangle
>
rectangles
;
rectangles
=
run_detector_with_upscale
(
detector
,
img
,
upsampling_amount
,
detection_confidences
,
weight_indices
);
return
boost
::
python
::
make_tuple
(
rectangles
,
detection_confidences
,
weight_indices
);
}
};
};
}
}
...
...
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