Kate Dunagan – Final Project

Watch a brief explanation of the SVG Processing, please follow this link:

Kate Big screenOrca       2015-03-23 15.18.22   Processing is an open-source programming language that encourages the use of  technologial devices like sensors, motors and arduino.  Our goal here is to create an  interesting story to get people to interact with technology using these gadgets. I loved  working with SVG files or Scalable Vector Graphics.

2015-03-23 15.21.00

Built in Illustrator layer by layer, the processing allows the SVG drawing to come in layer by layer by moving the mouse back and forth across the pad.

Ricky and OrcaSketch               2015-03-23 15.24.06

By modifying the code to use facial detection instead of a mouse, the user sketches the drawing in as they move across the range of the camera. To help engage the sketcher, by the pressing any keyboard key, an audio file of Orca’s talking to each other is activated.

 

//click mouse , hit any key to play audio
//Ricard Marxer's GEOMERATIVE HelloSplitShapes example
//svg Illustration by Kate Dunagan, revised by Austin Lee and Kate Dunagan on 3/14/15
//INSTALL openCV library from Sketch > Import Library > Add Library > Type 'opencv' in the search bar
//BELOW WE IMPORT LIBRARIES
import gab.opencv.*;
import processing.video.*;
import java.awt.*;
import geomerative.*; 

import ddf.minim.*; //sound
import ddf.minim.analysis.*; //sound
Minim minim; //sound
AudioPlayer song; //sound
FFT fft; //sound
int kateX;

RShape shp;

int first = 0;
//WE CREATE TWO OBJECTS video OF TYPE Capture AND myopencv OF TYPE OPENCV
Capture video; //im creating a video feed from my camera
OpenCV myopencv; //you can use the open cv

void setup() {
 //SETTING UP REGULAR STUFF
 // size(640, 480);
 size( displayWidth, displayHeight);
 smooth();
 // VERY IMPORTANT: Allways initialize the library before using it
 RG.init(this);

 shp = RG.loadShape("orcaSeattleDrawing4a.svg");
 shp = RG.centerIn(shp, g, 0); //0 is using the whole screen for the graphic, 100 is much smaller
 //TELLING video AND myopencv ITS SIZE
 video = new Capture(this, 640/2, 480/2); //small the size the faster it will play-take away the /2 and it is full size
 myopencv = new OpenCV(this, 640/2, 480/2); //this is the same as above line
 //TELLING myopencv TO LOAD FRONT CAMERA (WEBCAM) SO IT CAN START DETECTING
 myopencv.loadCascade(OpenCV.CASCADE_FRONTALFACE); //load cascade is the info on the frontal view of the face
 //START THE CAMERA
 video.start();
 minim = new Minim(this); //Audio
 //song = minim.loadFile("test.mp3"); //Audio
 song = minim.loadFile("OrcaWhalesTalking_SoundBible.com_871053726.mp3"); //Audio
 
}

void draw() {
 
 //MAKING THE CAMERA IMAGE BIGGER
 //scale(3); //say scale 1 and the image is 1/2 the size 
 //LOADING IMAGES FROM THE VIDEO CAPTURE
 myopencv.loadImage(video); //(video) is where you load the movie
 //DISPLAYING THE VIDEO ON THE SCREEN
 image(video, 0, 0 );
 //COLOR AND STROKE SETTINGS FOR THE GREEN RECTANGLE
 noFill();
 stroke(0, 255, 0); //this is green. if you try other values
 strokeWeight(3);
 //STORING THE FACES DETECTED SO THAT WE CAN USE THIS INFORMATION LATER
 Rectangle[] faces = myopencv.detect(); //this is where the faces are stored
 //PRINTING IN THE CONSOLE NUMBER OF FACES DETECTED
 println("Number of Faces Detected:" + faces.length); //faces.length is 
 if (faces.length>0) { //this is where we add a change -if more than one face comes in to view, the colors all go gray
 filter(GRAY);
 }


 //DRAWING RECTANGLES ON THE FACES SO THAT WE CAN SEE A VISUAL INDICATION THAT IT DETECTED
 for (int i = 0; i < faces.length; i++) {
 rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
 kateX= faces[i].x;
 }


 translate(width/2, height/2);
 background(0); //(165,150,150);
 // background(#2D4D83);

 noFill();
 stroke(255, 200);
 //float splitPos = map(kateX, 0, width/3, 0, 1);
 float splitPos = map(kateX, 1, width/6, 0, 1); ///4 shrinks drawing enough to fit the screen
 RShape[] splitShapes = RG.split(shp, splitPos);

 RG.shape(splitShapes[first]);
  
}

void keyPressed()
{
 song.loop(); //Audio
 fft = new FFT( song.bufferSize(), song.sampleRate() ); //Audio
}

//KEEPS CHECKING IF THE CAMERA IS ON, IF IT IS, IT KEEPS READING VIDEO DATA FROM IT
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