mirror of https://github.com/davisking/dlib.git
re-arrange, use vector<double> to facilitate pass back to python
This commit is contained in:
parent
154f9e4931
commit
9b78932ab1
|
@ -350,6 +350,18 @@ object_detector<scan_fhog_pyramid<pyramid_down<6>>>.")
|
|||
ensures \n\
|
||||
- This function runs the object detector on the input image and returns \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\
|
||||
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\
|
||||
|
@ -383,18 +395,6 @@ ensures \n\
|
|||
ensures \n\
|
||||
- This function runs the object detector on the input image and returns \n\
|
||||
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_pickle(serialize_pickle<type>());
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace dlib
|
|||
std::vector<rect_detection>& rect_detections,
|
||||
std::vector<rectangle>& rectangles,
|
||||
std::vector<double>& detection_confidences,
|
||||
std::vector<int>& weight_indices
|
||||
std::vector<double>& weight_indices
|
||||
)
|
||||
{
|
||||
rectangles.clear();
|
||||
|
@ -37,7 +37,7 @@ namespace dlib
|
|||
boost::python::object img,
|
||||
const unsigned int upsampling_amount,
|
||||
std::vector<double>& detection_confidences,
|
||||
std::vector<int>& weight_indices
|
||||
std::vector<double>& weight_indices
|
||||
)
|
||||
{
|
||||
pyramid_down<2> pyr;
|
||||
|
@ -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
|
||||
{
|
||||
simple_object_detector detector;
|
||||
|
@ -124,7 +142,7 @@ namespace dlib
|
|||
const unsigned int upsampling_amount_)
|
||||
{
|
||||
std::vector<double> detection_confidences;
|
||||
std::vector<int> weight_indices;
|
||||
std::vector<double> weight_indices;
|
||||
|
||||
return run_detector_with_upscale(detector, img, upsampling_amount_,
|
||||
detection_confidences, weight_indices);
|
||||
|
@ -133,27 +151,12 @@ namespace dlib
|
|||
std::vector<dlib::rectangle> run_detector2 (boost::python::object img)
|
||||
{
|
||||
std::vector<double> detection_confidences;
|
||||
std::vector<int> weight_indices;
|
||||
std::vector<double> weight_indices;
|
||||
return run_detector_with_upscale(detector, img, upsampling_amount,
|
||||
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);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue