| 126 | } |
| 127 | |
| 128 | inline std::vector<dlib::rectangle> run_detectors_with_upscale1 ( |
| 129 | std::vector<simple_object_detector >& detectors, |
| 130 | py::array img, |
| 131 | const unsigned int upsampling_amount, |
| 132 | const double adjust_threshold, |
| 133 | std::vector<double>& detection_confidences, |
| 134 | std::vector<unsigned long>& weight_indices |
| 135 | ) |
| 136 | { |
| 137 | pyramid_down<2> pyr; |
| 138 | |
| 139 | std::vector<rectangle> rectangles; |
| 140 | std::vector<rect_detection> rect_detections; |
| 141 | |
| 142 | if (is_image<unsigned char>(img)) |
| 143 | { |
| 144 | array2d<unsigned char> temp; |
| 145 | if (upsampling_amount == 0) |
| 146 | { |
| 147 | evaluate_detectors(detectors, numpy_image<unsigned char>(img), rect_detections, adjust_threshold); |
| 148 | split_rect_detections(rect_detections, rectangles, |
| 149 | detection_confidences, weight_indices); |
| 150 | return rectangles; |
| 151 | } |
| 152 | else |
| 153 | { |
| 154 | pyramid_up(numpy_image<unsigned char>(img), temp, pyr); |
| 155 | unsigned int levels = upsampling_amount-1; |
| 156 | while (levels > 0) |
| 157 | { |
| 158 | levels--; |
| 159 | pyramid_up(temp); |
| 160 | } |
| 161 | |
| 162 | evaluate_detectors(detectors, temp, rect_detections, adjust_threshold); |
| 163 | for (unsigned long i = 0; i < rect_detections.size(); ++i) |
| 164 | rect_detections[i].rect = pyr.rect_down(rect_detections[i].rect, |
| 165 | upsampling_amount); |
| 166 | split_rect_detections(rect_detections, rectangles, |
| 167 | detection_confidences, weight_indices); |
| 168 | |
| 169 | return rectangles; |
| 170 | } |
| 171 | } |
| 172 | else if (is_image<rgb_pixel>(img)) |
| 173 | { |
| 174 | array2d<rgb_pixel> temp; |
| 175 | if (upsampling_amount == 0) |
| 176 | { |
| 177 | evaluate_detectors(detectors, numpy_image<rgb_pixel>(img), rect_detections, adjust_threshold); |
| 178 | split_rect_detections(rect_detections, rectangles, |
| 179 | detection_confidences, weight_indices); |
| 180 | return rectangles; |
| 181 | } |
| 182 | else |
| 183 | { |
| 184 | pyramid_up(numpy_image<rgb_pixel>(img), temp, pyr); |
| 185 | unsigned int levels = upsampling_amount-1; |
no test coverage detected