sábado, 10 de julho de 2010

Processing code

/**
* Instants of metamorphosis v.02 // an interactive video installation // DOUBLE collective, UK/Brazil, June/July 2010; processing code: Clarissa Ribeiro.
* Clarissa Ribeiro: art direction, video and sound edition and performance
* Renata La Rocca: artistic direction and tests

* move around in the scene, over a projection onto the ground, to load and play movie files.
*/

import fullscreen.*;
import processing.video.*;
import JMyron.*;
import ddf.minim.*;

Minim minim;
AudioPlayer player;
FullScreen fs;
Movie myMovie;
Movie myMovie2;
Movie myMovie3;
Movie myMovie4;
JMyron m; //a camera object

//variables to maintain the floating movie
float myMoviex = 320;
float myMoviey = 240;
float myMoviedestx = 320;
float myMoviedesty = 240;


//variables to maintain the floating moviee
float myMovie2x = 320;
float myMovie2y = 240;
float myMovie2destx = 320;
float myMovie2desty = 240;

//variables to maintain the floating movie
float myMovie3x = 320;
float myMovie3y = 240;
float myMovie3destx = 320;
float myMovie3desty = 240;

//variables to maintain the floating movie
float myMovie4x = 320;
float myMovie4y = 240;
float myMovie4destx = 320;
float myMovie4desty = 240;


void setup() {
// set size to 640x480
size(640, 480);
// The background COLOR IS BLACK:
background(0,0,0);

//new Minim:
minim = new Minim(this);
// load a file, give the AudioPlayer buffers that are 2048 samples long
player = minim.loadFile("breathing.wav", 2048);
player.loop();

// Create the fullscreen object
fs = new FullScreen(this);

// enter fullscreen mode
fs.enter();

// Load and play the video in a loop// according to the sculpture dimmension, change the video file: medium, big or small, or use the original.mov
myMovie = new Movie(this, "touch.3gp");
myMovie2 = new Movie(this, "taste.3gp");
myMovie3 = new Movie(this, "smell.3gp");
myMovie4 = new Movie(this, "look.3gp");
myMovie.loop();
myMovie2.loop();
myMovie3.loop();
myMovie4.loop();
m = new JMyron();//make a new instance of the object
m.start(width,height);//start a capture at 640x480
m.trackColor(255,255,255,256*3-100);//track white / must ajust the 3-5
m.update();
m.adaptivity(10); // how fast the white is capted! it was 100
m.adapt();// immediately take a snapshot of the background for differencing
println("Myron " + m.version());
rectMode(CENTER);
noStroke();
}

void movieEvent(Movie myMovie) {
myMovie.read();
}

void draw() {
m.update();//update the camera view
drawCamera();

int[][] centers = m.globCenters();//get the center points
//draw all the dots while calculating the average.
float avX=0;
float avY=0;
for(int i=0;i fill(0);
// image(myMovie, 0,0);
avX += centers[i][0];
avY += centers[i][1];
}
if(centers.length-1>0){
avX/=centers.length-1;
avY/=centers.length-1;
}
//draw the image. if you want the movie starts in the center of the screen, use myMoviex/2 and myMoviey/2.
// to star in the right corner: only myMoviex and myMoviex. To start in the left, myMoviex/4 and myMoviexy/4.
image(myMovie, myMoviex, myMoviey);
image(myMovie2, myMoviex/4, myMoviey/4);
image(myMovie3, myMoviex/2, myMoviey/2);
image(myMovie4, myMoviex/-4, myMoviey/-4);

//update the location of the thing on the screen.
if(!(avX==0&&avY==0)&¢ers.length>1){
myMoviedestx = avX;
myMoviedesty = avY;
}
//update the location of the 2 thing on the screen.
if(!(avX==0&&avY==0)&¢ers.length>1){
myMovie2destx = avX;
myMovie2desty = avY;
}
//update the location of the 2 thing on the screen.
if(!(avX==0&&avY==0)&¢ers.length>1){
myMovie3destx = avX;
myMovie3desty = avY;
}
//update the location of the 2 thing on the screen.
if(!(avX==0&&avY==0)&¢ers.length>1){
myMovie4destx = avX;
myMovie4desty = avY;
}
myMoviex += (myMoviedestx-myMoviex)/1f;
myMoviey += (myMoviedesty-myMoviey)/1.f;
myMovie2x += (myMovie2destx-myMoviex)/1f;
myMovie2y += (myMovie2desty-myMoviey)/1.f;
myMovie3x += (myMovie3destx-myMoviex)/1f;
myMovie3y += (myMovie3desty-myMoviey)/1.f;
myMovie4x += (myMovie4destx-myMoviex)/1f;
myMovie4y += (myMovie4desty-myMoviey)/1.f;

fill(0,0,0);
ellipseMode(CENTER);
//ellipse(myMoviex,myMoviey,0,0);
}

void drawCamera(){
loadPixels();

updatePixels();
}

Sem comentários:

Enviar um comentário