Creating Installation 3

12 Jan

After working with the face tracking code and blur feature with mouse tracking I now been working on implementing these two ideas together. Using the code from face tracking and the blur feature I implemented on my earlier mouse tracking implementation i was able to finalise the project into a working installation.

Using the blur function i was able to remove the box tracking the face and place the blur in its place. Subsequently this made the screen blur when a face was detected on screen and no blur when no face was detected. The overall process of this implementation wasn’t to challenging. I found the whole process very interesting, from being able to understand the code and then being able to manipulate what happens on the screen.

Below I shall be posting a video of the process working and the code used to create the effect.

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

// initiate video and openCV
Capture video;
OpenCV opencv;

void setup() {
size(640, 480);
//scale video down to make it run smoother
video = new Capture(this, 640/2, 480/2);
opencv = new OpenCV(this, 640/2, 480/2);
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);

video.start();
}

void draw() {
//scale everything back up to fit window
scale(2);
opencv.loadImage(video);

image(video, 0, 0 );
video.loadPixels();

noFill();
stroke(0, 255, 0);
strokeWeight(3);

//create array for faces
Rectangle[] faces = opencv.detect();
println(faces.length);

noFill();
noStroke();
for( int i=0; i<faces.length; i++ ) {
rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height );
blur();
}
}

void blur() {
filter(BLUR, 6);
}

void captureEvent(Capture c) {
c.read();
}

Advertisements

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: