A simple class for webcam face-detection implementation in your projects using Processing.
You'll be able to receive useful data easily from your webcam and use it in your own Processing project.
The current version offers:
- Face position tracking.
- Facial features (eyebrows, eyes and mouth) position tracking.
- Cropping a face from the webcam output.
- Cropping facial features.
Future features:
- Get a measurement of eyes and mouth amplitude.
- Get a measurement of eyebrows height
- Much more...
First of all you'll need to import the class into your project.
- Download the .zip.
- Extract
- Copy Face-Class-main/face_controller/face.pde next to the main file of your Processing project.
- Now you can call the Face class inside your project!
To make use of the Face class you just need to create an object of the Face class and call Process() every frame. See methods for more info.
FaceController fc;
void setup() {
size(640, 480);
fc = new FaceController(this, "Camera Name");
//You can also call process() inside setup();
}
void draw() {
background(0);
fc.process();
PImage faceImg = fc.getFaceCrop();
image(faceImg, width/2 - faceImg.width/2, height/2 - faceImg.height/2, faceImg.width, faceImg.height);
}
An example of how to draw a face crop in the middle of the canvas. Check out more here.
Method | Type | Description | Parameters |
---|---|---|---|
FaceController | Constructor | Initializes face and facial features objects and loads face_landmark_model.dat and haarcascade_frontalface_default.xml |
|
FaceController (overloaded) | Constructor | Initializes face and facial features objects and loads face_landmark_model.dat and haarcascade_frontalface_default.xml |
|
FaceController (overloaded) | Constructor | Initializes face and facial features objects and loads face_landmark_model.dat and haarcascade_frontalface_default.xml |
|
process | boolean | Updates face variables using camera's output. Returns if the camera was available or not. | |
process (overloaded) | boolean | Updates face variables using camera's output. Returns if the camera was available or not. | boolean debug |
getCamScale | float | Returns the scale of the camera | |
getCamSize | PVector | Returns the original size of the camera | |
getCenter | PVector | Returns the coordinates of the center of the face | |
getReference | float | Returns face distance reference | |
getFace | RealFace | Returns the raw face object used in FaceController | |
getFaceCrop | PImage | Returns a crop of the face detected in the camera output | |
getLeftEyebrow | RealEyebrow | Returns the raw left eyebrow object used in FaceController | |
getRightEyebrow | RealEyebrow | Returns the raw right eyebrow object used in FaceController | |
getLeftEye | RealEye | Returns the raw left eye object used in FaceController | |
getLeftEyeCrop | PImage | Returns a crop of the left eye detected in the camera output | |
getRightEye | RealEye | Returns the raw right eye object used in FaceController | |
getRightEyeCrop | PImage | Returns a crop of the right eye detected in the camera output | |
getMouth | RealMouth | Returns the raw mouth object used in FaceController | |
getMouthCrop | PImage | Returns a crop of the mouth detected in the camera output | |
void | Prints face data |