Skip to content

A simple class for face-detection implementation in your own project.

Notifications You must be signed in to change notification settings

Chgv99/Face-Class

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EnglishEspañol

Face Class

A simple class for webcam face-detection implementation in your projects using Processing.

FeaturesUsageMethods

Features

You'll be able to receive useful data easily from your webcam and use it in your own Processing project.

The current version offers:
  1. Face position tracking.
  2. Facial features (eyebrows, eyes and mouth) position tracking.
  3. Cropping a face from the webcam output.
  4. Cropping facial features.
Future features:
  1. Get a measurement of eyes and mouth amplitude.
  2. Get a measurement of eyebrows height
  3. Much more...

Usage

First of all you'll need to import the class into your project.

  1. Download the .zip.
  2. Extract
  3. Copy Face-Class-main/face_controller/face.pde next to the main file of your Processing project.
  4. 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.

Methods

Method Type Description Parameters
FaceController Constructor Initializes face and facial features objects and loads face_landmark_model.dat and haarcascade_frontalface_default.xml
  • PApplet parent (normally this)
  • String camera
FaceController (overloaded) Constructor Initializes face and facial features objects and loads face_landmark_model.dat and haarcascade_frontalface_default.xml
  • PApplet parent (normally this)
  • String camera
  • float size
FaceController (overloaded) Constructor Initializes face and facial features objects and loads face_landmark_model.dat and haarcascade_frontalface_default.xml
  • PApplet parent (normally this)
  • String camera
  • float size
  • float upperOffset
  • float lowerOffset
  • float leftOffset
  • float rightOffset
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
print void Prints face data

GitHub @Chgv99 · Twitter @ChgvCode

About

A simple class for face-detection implementation in your own project.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published