Herbert Spencer
YaBB Newbies
Offline
Posts: 8
Chile
Re: building time-image with iSight
Reply #7 - Sep 14th , 2008, 1:37am
Hi Tjerk, This is my version of the code. I guess it coud be optimized but is easy to read in spanish ;) /* TimeTwist por Herbert Spencer Se basa en el concepto la cuarta dimensión por Zbig Rybczynski, 1988 */ import processing.video.*; Capture fotograma; MovieMaker pelc; PFont px; PImage[] buffer; PImage timeTwist; boolean buffering; boolean record; int count; void setup() { size(320, 240); //frameRate(60); fotograma = new Capture(this, width, height, 24); px = createFont("Georgia", 16); textFont(px); textAlign(CENTER); buffering = true; buffer = new PImage[height]; count = 0; noStroke(); fill(255); } void draw() { if ((fotograma.available() == true) && buffering) { fotograma.read(); buffer[count] = fotograma.get(); if(count == (height-1)){ buffering = false; timeTwist = fotograma.get(); //print("done buffering!"); } else{ //print(count+", "); count++; background(0); rect((width/2)-40, height - count, 80, count); text("buffering",(width/2), (height - 8) - count); } } if((fotograma.available() == true) && !buffering){ // correr todos los valores a la izquierda for (int i = 1; i < height; i++){ buffer[i-1] = buffer[i]; } // poner el nuevo valor al final fotograma.read(); buffer[height-1] = fotograma.get(); // construir el fotograma "diagonal" loadPixels(); for (int y = 1; y < height; y++){ for(int x = 0; x < width-1; x++){ pixels[(width*y) + x] = buffer[y].pixels[(width*y) + x]; } } updatePixels(); //background(timeTwist); if(record){ pelc.addFrame(); } } } void keyPressed(){ if(key == ' '){ String filename = "movs/"+month()+"-"+day()+"-"+hour()+"-"+minute()+".mov"; pelc = new MovieMaker(this, width, height, filename, 24, MovieMaker.SORENSON, MovieMaker.HIGH); record = true; println("GRABANDO"); } if((key == 'q')||(key == 'Q')){ pelc.finish(); println("LISTO"); exit(); } }