mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Added face detection example program
This commit is contained in:
parent
47ec9a6634
commit
417c5578e1
@ -32,6 +32,7 @@ add_example(config_reader_ex)
|
|||||||
add_example(custom_trainer_ex)
|
add_example(custom_trainer_ex)
|
||||||
add_example(dir_nav_ex)
|
add_example(dir_nav_ex)
|
||||||
add_example(empirical_kernel_map_ex)
|
add_example(empirical_kernel_map_ex)
|
||||||
|
add_example(face_detection_ex)
|
||||||
add_example(fhog_ex)
|
add_example(fhog_ex)
|
||||||
add_example(fhog_object_detector_ex)
|
add_example(fhog_object_detector_ex)
|
||||||
add_example(file_to_code_ex)
|
add_example(file_to_code_ex)
|
||||||
|
47
examples/face_detection_ex.cpp
Normal file
47
examples/face_detection_ex.cpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
|
||||||
|
/*
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <dlib/image_processing/frontal_face_detector.h>
|
||||||
|
#include <dlib/gui_widgets.h>
|
||||||
|
#include <dlib/image_io.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace dlib;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
frontal_face_detector detector = get_frontal_face_detector();
|
||||||
|
image_window win;
|
||||||
|
for (int i = 1; i < argc; ++i)
|
||||||
|
{
|
||||||
|
array2d<unsigned char> img;
|
||||||
|
load_image(img, argv[i]);
|
||||||
|
pyramid_up(img);
|
||||||
|
std::vector<rectangle> dets = detector(img);
|
||||||
|
|
||||||
|
cout << "number of faces detected: " << dets.size() << endl;
|
||||||
|
win.clear_overlay();
|
||||||
|
win.set_image(img);
|
||||||
|
win.add_overlay(dets, rgb_pixel(255,0,0));
|
||||||
|
// Pause until the user hits the enter key
|
||||||
|
cin.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (exception& e)
|
||||||
|
{
|
||||||
|
cout << "\nexception thrown!" << endl;
|
||||||
|
cout << e.what() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user