| 328 | } |
| 329 | |
| 330 | void save_face_chips ( |
| 331 | numpy_image<rgb_pixel> img, |
| 332 | const std::vector<full_object_detection>& faces, |
| 333 | const std::string& chip_filename, |
| 334 | size_t size = 150, |
| 335 | float padding = 0.25 |
| 336 | ) |
| 337 | { |
| 338 | |
| 339 | int num_faces = faces.size(); |
| 340 | std::vector<chip_details> dets; |
| 341 | for (const auto& f : faces) |
| 342 | dets.push_back(get_face_chip_details(f, size, padding)); |
| 343 | dlib::array<matrix<rgb_pixel>> face_chips; |
| 344 | extract_image_chips(numpy_image<rgb_pixel>(img), dets, face_chips); |
| 345 | int i=0; |
| 346 | for (const auto& chip : face_chips) |
| 347 | { |
| 348 | i++; |
| 349 | if(num_faces > 1) |
| 350 | { |
| 351 | const std::string& file_name = chip_filename + "_" + std::to_string(i) + ".jpg"; |
| 352 | save_jpeg(chip, file_name); |
| 353 | } |
| 354 | else |
| 355 | { |
| 356 | const std::string& file_name = chip_filename + ".jpg"; |
| 357 | save_jpeg(chip, file_name); |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | |
| 362 | void save_face_chip ( |
| 363 | numpy_image<rgb_pixel> img, |
no test coverage detected