| 48 | // ---------------------------------------------------------------------------------------- |
| 49 | |
| 50 | int main(int argc, char** argv) |
| 51 | { |
| 52 | try |
| 53 | { |
| 54 | if (argc == 1) |
| 55 | { |
| 56 | cout << "Give some image files as arguments to this program." << endl; |
| 57 | return 0; |
| 58 | } |
| 59 | |
| 60 | frontal_face_detector detector = get_frontal_face_detector(); |
| 61 | image_window win; |
| 62 | |
| 63 | // Loop over all the images provided on the command line. |
| 64 | for (int i = 1; i < argc; ++i) |
| 65 | { |
| 66 | cout << "processing image " << argv[i] << endl; |
| 67 | array2d<unsigned char> img; |
| 68 | load_image(img, argv[i]); |
| 69 | // Make the image bigger by a factor of two. This is useful since |
| 70 | // the face detector looks for faces that are about 80 by 80 pixels |
| 71 | // or larger. Therefore, if you want to find faces that are smaller |
| 72 | // than that then you need to upsample the image as we do here by |
| 73 | // calling pyramid_up(). So this will allow it to detect faces that |
| 74 | // are at least 40 by 40 pixels in size. We could call pyramid_up() |
| 75 | // again to find even smaller faces, but note that every time we |
| 76 | // upsample the image we make the detector run slower since it must |
| 77 | // process a larger image. |
| 78 | pyramid_up(img); |
| 79 | |
| 80 | // Now tell the face detector to give us a list of bounding boxes |
| 81 | // around all the faces it can find in the image. |
| 82 | std::vector<rectangle> dets = detector(img); |
| 83 | |
| 84 | cout << "Number of faces detected: " << dets.size() << endl; |
| 85 | // Now we show the image on the screen and the face detections as |
| 86 | // red overlay boxes. |
| 87 | win.clear_overlay(); |
| 88 | win.set_image(img); |
| 89 | win.add_overlay(dets, rgb_pixel(255,0,0)); |
| 90 | |
| 91 | cout << "Hit enter to process the next image..." << endl; |
| 92 | cin.get(); |
| 93 | } |
| 94 | } |
| 95 | catch (exception& e) |
| 96 | { |
| 97 | cout << "\nexception thrown!" << endl; |
| 98 | cout << e.what() << endl; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | // ---------------------------------------------------------------------------------------- |
| 103 |
nothing calls this directly
no test coverage detected