1 | Simple Face Identification |
---|
2 | -------------------------- |
---|
3 | |
---|
4 | A simple approach to face identification, built on top of OpenCV and given a |
---|
5 | YARP network interface. |
---|
6 | |
---|
7 | The program has two modes of operation. The first is calibration, where each |
---|
8 | user must show their face to the camera separately - press the number keys to |
---|
9 | assign each user with a different ID. You can see which face is mapped to |
---|
10 | which ID at the bottom of the window. |
---|
11 | |
---|
12 | The second mode of operation is face detection, where each visible detected |
---|
13 | face is given an ID based on it's closest match (within a given error |
---|
14 | threshold) with the faces recorded during calibration. The boxes drawn around |
---|
15 | the faces display the closest matched image, the id and confidence value of the |
---|
16 | match. When in this mode the program sends the following YARP messages: |
---|
17 | |
---|
18 | Output port Bottle contents Meaning |
---|
19 | /faceident "user appeared" ID confidence A user has entered the view of the camera |
---|
20 | /faceident "user disappeared" ID The user has left the camera view |
---|
21 | |
---|
22 | You can also drive the program via yarp with the following input messages: |
---|
23 | |
---|
24 | Input port Bottle contents Meaning |
---|
25 | /faceident-ctrl "train" ID Train for this user |
---|
26 | /faceident-ctrl "detect" Switch to detection mode |
---|
27 | /faceident-ctrl "save" sessionname Save the detected faces |
---|
28 | /faceident-ctrl "load" sessionname Load previously detected faces |
---|
29 | /faceident-ctrl "clear" Clears all faces |
---|
30 | /faceident-ctrl "idle" Switch to idle mode, mostly frees up cpu |
---|
31 | /faceident-ctrl "multiimages" 1/0 Turn on or off multiple images per face, experimental |
---|
32 | /faceident-ctrl "errorthresh" value Set the error threshold (default 0.2) |
---|
33 | /faceident-ctrl "newimagethresh" value Set the threshold greater than which new images are |
---|
34 | stored in training (default 0.1) |
---|
35 | |
---|
36 | Faces are saved in png format along with a xml file to map them to id numbers. The sessionname |
---|
37 | will be prepended onto the filenames for the xml file and the image files, so you can save |
---|
38 | multiple sessions. |
---|
39 | |
---|
40 | Key Meaning |
---|
41 | 0-9 number keys Calibrate a given id against a face in the scene |
---|
42 | d Start detect mode, which will send YARP messages |
---|
43 | c Clear all faces in the database |
---|
44 | |
---|
45 | Requires: OpenCV, YARP |
---|
46 | |
---|
47 | Written and tested on Linux, but it should work in Windows too. At the moment |
---|
48 | you'll probably have to run it with: |
---|
49 | |
---|
50 | simple-faceident -cascade=/path/to/haarcascade_frontalface_alt.xml |
---|
51 | |
---|
52 | In order to find OpenCV's data, on my machine it's in: |
---|
53 | /usr/local/share/opencv/haarcascades/haarcascade_frontalface_alt.xml |
---|
54 | |
---|
55 | Todo: |
---|
56 | * Try normalised cross correlation instead of image differencing |
---|
57 | * Expose image size via yarp |
---|
58 | |
---|
59 | Questions to: |
---|
60 | |
---|
61 | dave@fo.am |
---|
62 | |
---|