Interactive Authoring – Face Warp


Processing, 2016

Visual music piece made using Processing and the openCV and Minim libraries. With facial tracking, the program is able to synthesize sounds and visuals. Sometimes the face detection program will recognize faces in places where there may not actually be any, causing it to glitch every so often.

By warping the face of whoever is using the program, the aim is to make it feel uncomfortable and unnatural. Technology has paradoxically become both a reflection of the human experience, while also being a very dehumanizing thing. We have put everything it means to be human into the digital realm, and yet existing within it places a barrier on existence and makes us numb to reality.

import gab.opencv.*;
import java.awt.Rectangle;
import processing.video.*;
import ddf.minim.*;
import ddf.minim.ugens.*;
import beads.*;
Minim minim;
AudioOutput out;
Oscil wave;
OpenCV opencv;
Rectangle[] faces;
Capture video;
AudioContext ac;
Function function;
PImage img, mask, radius;
int faceX=200;
float addBass = 0;
float addSlow=0;
int dual=0;
int type = 1;
int X1=0;
int X2=0;
int Y1=0;
int Y2=0;
int counter=1;
int counterExit=1;
int pitch=0;
float two=0;
int randKill=0;
int opacTrig = 0;
class PopInstrument implements Instrument
{
Oscil sineOsc;
ADSR adsr;
PopInstrument( float frequency, float amplitude )
{
if (type==1) {
sineOsc = new Oscil( frequency, amplitude, Waves.SAW );
}
if (type==2) {
sineOsc = new Oscil( frequency, amplitude, Waves.TRIANGLE );
}
adsr = new ADSR( 0.5, 0.01, 0.05, 0.5, 0.5 );
sineOsc.patch( adsr );
}
void noteOn( float dur )
{
adsr.noteOn();
adsr.patch( out );
}
void noteOff()
{
adsr.unpatchAfterRelease( out );
adsr.noteOff();
}
}
void setup() {
frameRate(60);
size(640, 360);
background(0);
colorMode(HSB);
minim = new Minim( this );
out = minim.getLineOut();
wave = new Oscil( 0, 0.5f, Waves.SINE );
wave.patch( out );
ac = new AudioContext();
video = new Capture(this, width, height);
video.start();
noStroke();
smooth();
opencv = new OpenCV(this, width, height);
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
radius = loadImage(“radial3.png”);
}

void draw() {
counter=counter+1;

if (counter>2) {
counter=1;
}
video.read();
opencv.loadImage(video);
video.loadPixels();
WavePlayer freqModulator = new WavePlayer(ac, 50, Buffer.SINE);
faces = opencv.detect();
function = new Function(freqModulator) {
public float calculate() {
return x[0] * 100.0 + pitch;
}
};
WavePlayer wp = new WavePlayer(ac, function, Buffer.SINE);
beads.Gain g = new beads.Gain(ac, 1, 0.8);
g.addInput(wp);
ac.out.addInput(g);
ac.start();

if (type>2) {
type=1;
}
if (faces.length==0) {
counterExit=counterExit+1;
}
if (faces.length>0) {
counterExit=1;
}
if (faces.length==2) {
two=.2;
randKill=60;
if (type==1) {
type=2;
}
if (type==2) {
type=1;
}
}
for (int i = 0; i < faces.length; i++) { //facedraew
pitch = (abs(X1-X2)+abs(Y1-Y2))*5;

if (counter==1) {
X1=faces[i].x;
}
if (counter==2) {
X2=faces[i].x;
}
if (counter==1) {
Y1=faces[i].y;
}
if (counter==2) {
Y2=faces[i].y;
}
float amp = map(200-faces[i].width, 0, height, 1, 0 );
wave.setAmplitude( amp );
float freq = map( (150-(faces[i].x/2)+random(-5, 5)*(addBass/random(1, 3))), 0, width, 110, 880 );
wave.setFrequency( freq );
if (mousePressed) {
out.playNote( 0, 0.1+addSlow+two, new PopInstrument( 2980-(faces[i].width*9)+random(-60+randKill, 60-randKill)+addBass, ((36-(faces[i].y/5) )/10)) );
if (opacTrig<300) {
opacTrig=opacTrig+30;
}
} else {
if (opacTrig>0) {
opacTrig=opacTrig-30;
}
}
if (faces[i].width<200) {
tint(166, (150-faces[i].width)*2, 254, 255);
}
if (faces[i].width>200) {
tint(281-dual, faces[i].width-182, 254, 255);
}
if (faces[i].width>0&&faces[i].width<180) {
addBass=-2000;
addSlow=.1;
}
if (faces[i].width>180) {
addBass=0;
addSlow=0;
}
for (int s = 0; s<2; s++) {
image(video, -10+random(20), (faces[i].y*2)+random(-60, 60), 50+random(0, 60), 50+random(0, 60), (faces[+i].x)+36, faces[+i].y+9, (faces[i].width)+faces[i].x+-42, (faces[+i].height)+faces[i].y+-42);
image(video, 14+random(20), (faces[i].y*2)+random(-55, 55), 50+random(0, 60), 50+random(0, 60), (faces[+i].x)+94, faces[+i].y+47, (faces[i].width)+faces[i].x+-11, (faces[+i].height)+faces[i].y+-86);
image(video, 62+random(20), (faces[i].y*2)+random(-50, 50), 50+random(0, 60), 50+random(0, 60), (faces[+i].x)+69, faces[+i].y+56, (faces[i].width)+faces[i].x+-47, (faces[+i].height)+faces[i].y+-66);
image(video, 103+random(20), (faces[i].y*2)+random(-45, 45), 50+random(0, 60), 50+random(0, 60), (faces[+i].x)+40, faces[+i].y+116, (faces[i].width)+faces[i].x+-30, (faces[+i].height)+faces[i].y+-33);
image(video, 147+random(20), (faces[i].y*2)+random(-40, 40), 50+random(0, 60), 50+random(0, 60), (faces[+i].x)+59, faces[+i].y+8, (faces[i].width)+faces[i].x+-33, (faces[+i].height)+faces[i].y+-106);
image(video, 186+random(20), (faces[i].y*2)+random(-35, 35), 50+random(0, 60), 50+random(0, 60), (faces[+i].x)+15, faces[+i].y+44, (faces[i].width)+faces[i].x+-20, (faces[+i].height)+faces[i].y+-47);
image(video, 215+random(20), (faces[i].y*2)+random(-30, 30), 50+random(0, 60), 50+random(0, 60), (faces[+i].x)+22, faces[+i].y+68, (faces[i].width)+faces[i].x+10, (faces[+i].height)+faces[i].y+-86);
image(video, 260+random(20), (faces[i].y*2)+random(-25, 20), 50+random(0, 60), 50+random(0, 60), (faces[+i].x)+60, faces[+i].y+102, (faces[i].width)+faces[i].x+-17, (faces[+i].height)+faces[i].y+-44);
image(video, 290+random(20), (faces[i].y*2)+random(-20, 20), 50+random(0, 60), 50+random(0, 60), (faces[+i].x)+37, faces[+i].y+124, (faces[i].width)+faces[i].x+-14, (faces[+i].height)+faces[i].y+-4);
image(video, 340+random(20), (faces[i].y*2)+random(-25, 25), 50+random(0, 60), 50+random(0, 60), (faces[+i].x)+22, faces[+i].y+58, (faces[i].width)+faces[i].x+-95, (faces[+i].height)+faces[i].y+-93);
image(video, 395+random(20), (faces[i].y*2)+random(-30, 30), 50+random(0, 60), 50+random(0, 60), (faces[+i].x)+54, faces[+i].y+-18, (faces[i].width)+faces[i].x+-38, (faces[+i].height)+faces[i].y+-141);
image(video, 413+random(20), (faces[i].y*2)+random(-35, 35), 50+random(0, 60), 50+random(0, 60), (faces[+i].x)+52, faces[+i].y+74, (faces[i].width)+faces[i].x+-55, (faces[+i].height)+faces[i].y+-64);
image(video, 455+random(20), (faces[i].y*2)+random(-45, 45), 50+random(0, 60), 50+random(0, 60), (faces[+i].x)+22, faces[+i].y+9, (faces[i].width)+faces[i].x+-42, (faces[+i].height)+faces[i].y+-42);
image(video, 501+random(20), (faces[i].y*2)+random(-50, 50), 50+random(0, 60), 50+random(0, 60), (faces[+i].x)+87, faces[+i].y+71, (faces[i].width)+faces[i].x+-42, (faces[+i].height)+faces[i].y+-79);
image(video, 552+random(20), (faces[i].y*2)+random(-55, 55), 50+random(0, 60), 50+random(0, 60), (faces[+i].x)+94, faces[+i].y+111, (faces[i].width)+faces[i].x+-43, (faces[+i].height)+faces[i].y+-33);
image(video, 595+random(20), (faces[i].y*2)+random(-60, 60), 50+random(0, 60), 50+random(0, 60), (faces[+i].x)+94, faces[+i].y+47, (faces[i].width)+faces[i].x+-11, (faces[+i].height)+faces[i].y+-86);
//the new bunch
image(video, 700-(faces[i].x*2)+random(20), random(20)+0, 50+random(20), 50+random(20), (faces[+i].x)+60, faces[+i].y+102, (faces[i].width)+faces[i].x+-45, (faces[+i].height)+faces[i].y+-44);
image(video, 700-(faces[i].x*2)+random(20), random(20)+40, 50+random(20), 50+random(20), (faces[+i].x)+84, faces[+i].y+124, (faces[i].width)+faces[i].x+-43, (faces[+i].height)+faces[i].y+-32);
image(video, 700-(faces[i].x*2)+random(20), random(20)+92, 50+random(20), 50+random(20), (faces[+i].x)+22, faces[+i].y+58, (faces[i].width)+faces[i].x+-95, (faces[+i].height)+faces[i].y+-93);
image(video, 700-(faces[i].x*2)+random(20), random(20)+131, 50+random(20), 50+random(20), (faces[+i].x)+54, faces[+i].y+-18, (faces[i].width)+faces[i].x+-38, (faces[+i].height)+faces[i].y+-141);
image(video, 700-(faces[i].x*2)+random(20), random(20)+184, 50+random(20), 50+random(20), (faces[+i].x)+52, faces[+i].y+74, (faces[i].width)+faces[i].x+-55, (faces[+i].height)+faces[i].y+-64);
image(video, 700-(faces[i].x*2)+random(20), random(20)+220, 50+random(20), 50+random(20), (faces[+i].x)+22, faces[+i].y+9, (faces[i].width)+faces[i].x+-42, (faces[+i].height)+faces[i].y+-42);
image(video, 700-(faces[i].x*2)+random(20), random(20)+265, 50+random(20), 50+random(20), (faces[+i].x)+87, faces[+i].y+71, (faces[i].width)+faces[i].x+-42, (faces[+i].height)+faces[i].y+-79);
image(video, 700-(faces[i].x*2)+random(20), random(20)+292, 50+random(20), 50+random(20), (faces[+i].x)+94, faces[+i].y+111, (faces[i].width)+faces[i].x+-43, (faces[+i].height)+faces[i].y+-33);
image(video, 700-(faces[i].x*2)+random(20), random(20)+320, 50+random(20), 50+random(20), (faces[+i].x)+94, faces[+i].y+47, (faces[i].width)+faces[i].x+-11, (faces[+i].height)+faces[i].y+-86);
}
tint(281, 255, 254, 300-abs(X1-X2)+abs(Y1-Y2)-random(50, 100)-opacTrig);
imageMode(CENTER);
image(radius, 733-(faces[i].x*2), (faces[i].y*2)+49, (2000-(faces[i].width*20))*.5, (2000-(faces[i].width*20))*.5);

imageMode(CORNER);
//text(faces[i].width,10,10);
}
if (counterExit==40) {
exit();
}
}

Advertisements
This entry was posted in Time-Based and tagged , , , . Bookmark the permalink.

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