diff --git a/tools/python/src/numpy_returns.cpp b/tools/python/src/numpy_returns.cpp index 776131fd7..1954ba382 100644 --- a/tools/python/src/numpy_returns.cpp +++ b/tools/python/src/numpy_returns.cpp @@ -82,8 +82,9 @@ py::list get_jitter_images(numpy_image img, size_t num_jitters = 1, b // ---------------------------------------------------------------------------------------- +template py::list get_face_chips ( - numpy_image img, + numpy_image img, const std::vector& faces, size_t size = 150, float padding = 0.25 @@ -99,7 +100,7 @@ py::list get_face_chips ( std::vector dets; for (const auto& f : faces) dets.push_back(get_face_chip_details(f, size, padding)); - dlib::array> face_chips; + dlib::array> face_chips; extract_image_chips(img, dets, face_chips); for (const auto& chip : face_chips) @@ -110,14 +111,15 @@ py::list get_face_chips ( return chips_list; } -numpy_image get_face_chip ( - numpy_image img, +template +numpy_image get_face_chip ( + numpy_image img, const full_object_detection& face, size_t size = 150, float padding = 0.25 ) { - numpy_image chip; + numpy_image chip; extract_image_chip(img, get_face_chip_details(face, size, padding), chip); return chip; } @@ -152,13 +154,33 @@ void bind_numpy_returns(py::module &m) py::arg("img"), py::arg("num_jitters")=1, py::arg("disturb_colors")=false ); - m.def("get_face_chip", &get_face_chip, - "Takes an image and a full_object_detection that references a face in that image and returns the face as a Numpy array representing the image. The face will be rotated upright and scaled to 150x150 pixels or with the optional specified size and padding.", - py::arg("img"), py::arg("face"), py::arg("size")=150, py::arg("padding")=0.25 - ); + { + const char* docs = "Takes an image and a full_object_detection that references a face in that image and returns the face as a Numpy array representing the image. The face will be rotated upright and scaled to 150x150 pixels or with the optional specified size and padding."; + m.def("get_face_chip", &get_face_chip, docs, py::arg("img"), py::arg("face"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chip", &get_face_chip, docs, py::arg("img"), py::arg("face"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chip", &get_face_chip, docs, py::arg("img"), py::arg("face"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chip", &get_face_chip, docs, py::arg("img"), py::arg("face"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chip", &get_face_chip, docs, py::arg("img"), py::arg("face"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chip", &get_face_chip, docs, py::arg("img"), py::arg("face"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chip", &get_face_chip, docs, py::arg("img"), py::arg("face"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chip", &get_face_chip, docs, py::arg("img"), py::arg("face"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chip", &get_face_chip, docs, py::arg("img"), py::arg("face"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chip", &get_face_chip, docs, py::arg("img"), py::arg("face"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chip", &get_face_chip, docs, py::arg("img"), py::arg("face"), py::arg("size")=150, py::arg("padding")=0.25); + } - m.def("get_face_chips", &get_face_chips, - "Takes an image and a full_object_detections object that reference faces in that image and returns the faces as a list of Numpy arrays representing the image. The faces will be rotated upright and scaled to 150x150 pixels or with the optional specified size and padding.", - py::arg("img"), py::arg("faces"), py::arg("size")=150, py::arg("padding")=0.25 - ); + { + const char* docs = "Takes an image and a full_object_detections object that reference faces in that image and returns the faces as a list of Numpy arrays representing the image. The faces will be rotated upright and scaled to 150x150 pixels or with the optional specified size and padding."; + m.def("get_face_chips", &get_face_chips, docs, py::arg("img"), py::arg("faces"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chips", &get_face_chips, docs, py::arg("img"), py::arg("faces"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chips", &get_face_chips, docs, py::arg("img"), py::arg("faces"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chips", &get_face_chips, docs, py::arg("img"), py::arg("faces"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chips", &get_face_chips, docs, py::arg("img"), py::arg("faces"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chips", &get_face_chips, docs, py::arg("img"), py::arg("faces"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chips", &get_face_chips, docs, py::arg("img"), py::arg("faces"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chips", &get_face_chips, docs, py::arg("img"), py::arg("faces"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chips", &get_face_chips, docs, py::arg("img"), py::arg("faces"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chips", &get_face_chips, docs, py::arg("img"), py::arg("faces"), py::arg("size")=150, py::arg("padding")=0.25); + m.def("get_face_chips", &get_face_chips, docs,py::arg("img"), py::arg("faces"), py::arg("size")=150, py::arg("padding")=0.25); + } }