| 110 | |
| 111 | |
| 112 | inline double test_shape_predictor_with_images_py ( |
| 113 | const py::list& pyimages, |
| 114 | const py::list& pydetections, |
| 115 | const py::list& pyscales, |
| 116 | const shape_predictor& predictor |
| 117 | ) |
| 118 | { |
| 119 | const unsigned long num_images = py::len(pyimages); |
| 120 | const unsigned long num_scales = py::len(pyscales); |
| 121 | if (num_images != py::len(pydetections)) |
| 122 | throw dlib::error("The length of the detections list must match the length of the images list."); |
| 123 | |
| 124 | if (num_scales > 0 && num_scales != num_images) |
| 125 | throw dlib::error("The length of the scales list must match the length of the detections list."); |
| 126 | |
| 127 | std::vector<std::vector<full_object_detection> > detections(num_images); |
| 128 | std::vector<std::vector<double> > scales; |
| 129 | if (num_scales > 0) |
| 130 | scales.resize(num_scales); |
| 131 | dlib::array<numpy_image<unsigned char>> images(num_images); |
| 132 | |
| 133 | // Now copy the data into dlib based objects so we can call the testing routine. |
| 134 | for (unsigned long i = 0; i < num_images; ++i) |
| 135 | { |
| 136 | const unsigned long num_boxes = py::len(pydetections[i]); |
| 137 | for (py::iterator det_it = pydetections[i].begin(); |
| 138 | det_it != pydetections[i].end(); |
| 139 | ++det_it) |
| 140 | detections[i].push_back(det_it->cast<full_object_detection>()); |
| 141 | |
| 142 | assign_image(images[i], pyimages[i].cast<py::array>()); |
| 143 | if (num_scales > 0) |
| 144 | { |
| 145 | if (num_boxes != py::len(pyscales[i])) |
| 146 | throw dlib::error("The length of the scales list must match the length of the detections list."); |
| 147 | for (py::iterator scale_it = pyscales[i].begin(); scale_it != pyscales[i].end(); ++scale_it) |
| 148 | scales[i].push_back(scale_it->cast<double>()); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | return test_shape_predictor_with_images(images, detections, scales, predictor); |
| 153 | } |
| 154 | |
| 155 | inline double test_shape_predictor_with_images_no_scales_py ( |
| 156 | const py::list& pyimages, |
no test coverage detected