Facial Recognition with masks | Processing

Recently I have been looking into applying masks to my interactive idea. My interactive idea involves the theory of having your identity taken away from you, so I thought applying a mask (in this case an image) to the area where the face is detected. The image says “Smile and wave if you need to” because through testing at home I realised that my friends that had only seen the piece for the first time instantly started to move other parts of their body seeing as their face had been censored out. Most people waved, others turned to doing their hair, perhaps because thats the only part of the head left on show they felt it was the only part of them that they could distinguish as their own identity.

The code below is the setup for the image I applied to my program. It was a straight forward process and ran very smoothly without any crashes.

import gab.opencv.*;
import processing.video.*;
import java.awt.*;

Capture video;
OpenCV opencv;

//Stored image in mask
PImage mask;

void setup() {
  size(640, 480);
  video = new Capture(this, 640/2, 480/2);
  opencv = new OpenCV(this, 640/2, 480/2);
  mask = loadImage("nothingnew6.jpg");

void draw() {
  mask = loadImage("nothingnew6.jpg");

  image(video, 0, 0 );

  Rectangle[] faces = opencv.detect();

  for (int i = 0; i < faces.length; i++) {
    println(faces[i].x + "," + faces[i].y);
    mask.resize(faces[i].width+30, faces[i].height+30);
    image(mask,faces[i].x-10, faces[i].y-10);

void captureEvent(Capture c) {

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s