-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlandmark.cpp
More file actions
46 lines (37 loc) · 1.27 KB
/
landmark.cpp
File metadata and controls
46 lines (37 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include <iostream>
#include "dlib/gui_widgets.h"
#include "dlib/image_io.h"
#include "dlib/image_processing.h"
#include "dlib/image_processing/frontal_face_detector.h"
#include "dlib/image_processing/render_face_detections.h"
using namespace dlib;
using std::cout;
using std::cin;
using std::endl;
int main(int argc, char *argv[]) {
if (argc < 3) {
cout << "Usage: landmark <image_path> <shape_predictor_68_face_landmarks.dat_path>\n";
return -1;
}
frontal_face_detector detector = get_frontal_face_detector();
shape_predictor predictor;
deserialize(argv[2]) >> predictor;
array2d<unsigned char> img;
load_image(img, argv[1]);
std::vector<rectangle> dets = detector(img);
cout << "Number of faces detected: " << dets.size() << endl;
std::vector<full_object_detection> faces;
for (unsigned int i = 0; i < dets.size(); ++i) {
full_object_detection shape = predictor(img, dets[i]);
cout << "number of parts: "<< shape.num_parts() << endl;
faces.push_back(shape);
}
image_window win;
win.clear_overlay();
win.set_image(img);
win.add_overlay(dets, rgb_pixel(255,0,0));
win.add_overlay(render_face_detections(faces));
cout << "Hit enter..." << endl;
cin.get();
return 0;
}