| 26 | } |
| 27 | |
| 28 | std::vector<mmod_rect> detect ( |
| 29 | py::array pyimage, |
| 30 | const int upsample_num_times |
| 31 | ) |
| 32 | { |
| 33 | pyramid_down<2> pyr; |
| 34 | std::vector<mmod_rect> rects; |
| 35 | |
| 36 | // Copy the data into dlib based objects |
| 37 | matrix<rgb_pixel> image; |
| 38 | if (is_image<unsigned char>(pyimage)) |
| 39 | assign_image(image, numpy_image<unsigned char>(pyimage)); |
| 40 | else if (is_image<rgb_pixel>(pyimage)) |
| 41 | assign_image(image, numpy_image<rgb_pixel>(pyimage)); |
| 42 | else |
| 43 | throw dlib::error("Unsupported image type, must be 8bit gray or RGB image."); |
| 44 | |
| 45 | // Upsampling the image will allow us to detect smaller faces but will cause the |
| 46 | // program to use more RAM and run longer. |
| 47 | unsigned int levels = upsample_num_times; |
| 48 | while (levels > 0) |
| 49 | { |
| 50 | levels--; |
| 51 | pyramid_up(image, pyr); |
| 52 | } |
| 53 | |
| 54 | auto dets = net(image); |
| 55 | |
| 56 | // Scale the detection locations back to the original image size |
| 57 | // if the image was upscaled. |
| 58 | for (auto&& d : dets) { |
| 59 | d.rect = pyr.rect_down(d.rect, upsample_num_times); |
| 60 | rects.push_back(d); |
| 61 | } |
| 62 | |
| 63 | return rects; |
| 64 | } |
| 65 | |
| 66 | std::vector<std::vector<mmod_rect>> detect_mult ( |
| 67 | py::list imgs, |
nothing calls this directly
no test coverage detected