MCPcopy Create free account
hub / github.com/davisking/dlib / run_detector_with_upscale1

Function run_detector_with_upscale1

tools/python/src/simple_object_detector_py.h:38–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36
37
38 inline std::vector<dlib::rectangle> run_detector_with_upscale1 (
39 dlib::simple_object_detector& detector,
40 py::array img,
41 const unsigned int upsampling_amount,
42 const double adjust_threshold,
43 std::vector<double>& detection_confidences,
44 std::vector<unsigned long>& weight_indices
45 )
46 {
47 pyramid_down<2> pyr;
48
49 std::vector<rectangle> rectangles;
50 std::vector<rect_detection> rect_detections;
51
52 if (is_image<unsigned char>(img))
53 {
54 array2d<unsigned char> temp;
55 auto img_view = make_image_view(numpy_image<unsigned char>(img));
56
57 // Release the GIL so that this code can be run in parallel.
58 py::gil_scoped_release release;
59
60 if (upsampling_amount == 0)
61 {
62 detector(img_view, rect_detections, adjust_threshold);
63 split_rect_detections(rect_detections, rectangles,
64 detection_confidences, weight_indices);
65 return rectangles;
66 }
67 else
68 {
69 pyramid_up(img_view, temp, pyr);
70 unsigned int levels = upsampling_amount-1;
71 while (levels > 0)
72 {
73 levels--;
74 pyramid_up(temp);
75 }
76
77 detector(temp, rect_detections, adjust_threshold);
78 for (unsigned long i = 0; i < rect_detections.size(); ++i)
79 rect_detections[i].rect = pyr.rect_down(rect_detections[i].rect,
80 upsampling_amount);
81 split_rect_detections(rect_detections, rectangles,
82 detection_confidences, weight_indices);
83
84 return rectangles;
85 }
86 }
87 else if (is_image<rgb_pixel>(img))
88 {
89 array2d<rgb_pixel> temp;
90 auto img_view = make_image_view(numpy_image<rgb_pixel>(img));
91
92 // Release the GIL so that this code can be run in parallel.
93 py::gil_scoped_release release;
94
95 if (upsampling_amount == 0)

Callers 2

run_rect_detectorFunction · 0.85

Calls 6

make_image_viewFunction · 0.85
split_rect_detectionsFunction · 0.85
pyramid_upFunction · 0.85
errorClass · 0.85
sizeMethod · 0.45
rect_downMethod · 0.45

Tested by

no test coverage detected