Re Upload Interactive Authoring Final

https://vimeo.com/195821762

import processing.video.*;
import ipcapture.*;
import gab.opencv.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import java.awt.Rectangle;

Capture cam;
OpenCV opencv;
Rectangle[] Faces;
Minim minim;
AudioPlayer sound1, sound2, sound3;
FFT fft;
PImage img1;
PImage img2;
PImage img3;
PImage img4;
PImage img5;
boolean newFrame=false;
int i;
int j;

int quantity = 300;
float [] xPosition = new float[quantity];
float [] yPosition = new float[quantity];
int [] flakeSize = new int[quantity];
int [] direction = new int[quantity];
int minFlakeSize = 1;
int maxFlakeSize = 5;
int startingTime;

void setup () {
size(800, 600);
cam = new Capture(this, 800, 600);
surface.setResizable(true);
cam.start();
img1 = new PImage(80, 60);
opencv = new OpenCV(this, 800, 600);
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);

img1 = loadImage(“ice-tissue-forming.jpg”);
img2 = loadImage(“icicle.jpg”);
img3 = loadImage(“warm.jpg”);
img4 = loadImage(“Fire Gif.gif”);
img5 = loadImage(“Sunlight.png”);

minim = new Minim(this);
sound1 = minim.loadFile(“Sound Effect – Strong Wind Sound Effect For Free.mp3”, 1024);
sound2 = minim.loadFile(“Sound Effect – Heat of Day.mp3”, 1024);
sound3 = minim.loadFile(“Sound Effect – Evil Laugh Sound Effect.mp3”, 1024);

frameRate(30);
noStroke();
smooth();
startingTime = millis();
for(int j = 0; j < quantity; j++) {
flakeSize[j] = round(random(minFlakeSize, maxFlakeSize));
xPosition[j] = random(0, width);
yPosition[j] = random(0, height);
direction[j] = round(random(0, 8));
}

}
void captureEvent(Capture cam) {
cam.read();
newFrame = true;
}
void draw () {

cam.loadPixels();
image(cam, 0, 0);
Faces = opencv.detect();
opencv.loadImage(cam);

for (int i = 0; i < Faces.length; i++) {
noStroke();
fill(255, 0, 255, 0);
ellipse(Faces[i].x+100, Faces[i].y+100, Faces[i].width-30, Faces[i].height+40);

if (Faces[i].width <=40){
tint(255,20);
image(img1, 0,0,800,600);
sound1.play();
}
if (Faces[i].width >=40 && Faces[i].width <=68){
tint(255,20);
image(img2, 0,0,800,600);
sound2.pause();
}
if (Faces[i].width >=68 && Faces[i].width <=100){
tint(255,20);
image(img5, 0,0,800,600);
sound1.pause();
sound2.play();
}
if (Faces[i].width >=100 && Faces[i].width <=160){
tint(255,20);
image(img3, 0,0,800,600);
filter(BLUR, 1.5);
sound3.pause();
sound2.pause();
}
if (Faces[i].width >=160){
tint(255,20);
image(img4, 0,0,800,600);
filter(BLUR, 2);
sound3.play();
}
if (Faces[i].width <= 60){
noStroke();
for(int j = 0; j < xPosition.length; j++) {
ellipse(xPosition[j], yPosition[j], flakeSize[j], flakeSize[j]);
fill(255);
if(direction[j] == 0) {
xPosition[j] += map(flakeSize[j], minFlakeSize, maxFlakeSize, .1, .5);
} else {
xPosition[j] -= map(flakeSize[j], minFlakeSize, maxFlakeSize, .1, .5);
}
yPosition[j] += flakeSize[j] + direction[j];
if(xPosition[j] > width + flakeSize[j] || xPosition[j] < -flakeSize[j] || yPosition[j] > height + flakeSize[j]) {
xPosition[j] = random(0, width);
yPosition[j] = -flakeSize[j];
}
}
}
}
}

Advertisements
This entry was posted in Non 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