a coverflow treatment of a video sequence
in
Share your Work
•
6 months ago
Works in processing 1.5 but not in 2.0. Had me stumped for days. Here's a video:
http://www.youtube.com/watch?v=I-FWskXOdp4
Code:
import processing.video.*;
int maxImages = 250;
int router = 1;
int r=1;
Movie movie;
int ii = 0;
int iii = 0;
PImage[] gifs = new PImage[maxImages];
//these are all of the variables we need to run the coverflow
int imgCount = 250;
//int router = 1;
float imgX[] = new float[imgCount];
float imgY = 0;
float imgZ[] = new float[imgCount];
float imgWidth;
float imgHeight;
float Distance;
void setup()
{
frameRate(5);
size(1280, 900,P3D);
// size(1280, 900);
movie = new Movie(this, "Sample.mp4");
movie.loop();
imageMode(CENTER);
}
void setupImages() {
// gifs = new PImage[imgCount];
// for (int i = 3; i < imgCount-1; i++) {
// gifs[i] = loadImage("data/img" + nf(i, 3) + ".JPG");
println("we are in setupImages");
imageMode(CENTER);
}
//imageMode(CENTER);
//}
void calcImagePos(int i) {
imgX[i] = map(i, 0, 300, 0, width);
Distance = dist(imgX[i], imgY, mouseX, mouseY);
imgZ[i] = -Distance;
imgWidth = 900;
imgHeight = imgWidth * 0.75;
}
void displayImages(int i) {
pushMatrix();
// println("this is where the magic happens");
translate(imgX[i], height/2, imgZ[i]);
image(gifs[i], 0, 0, imgWidth/2.5, imgHeight/2.5);
popMatrix();
}
void draw() {
background(0);
if (router ==1){
// image(movie,0,0);
//image(gifs[ii],0,400);
// if(iii>0){
//for (int x = 1; x<200; ii++) {
//println(x);
//image(gifs[x],0,350);
//println(x);
// }
// }
}
if (router == 2){
// background(255);
movie.stop();
for (int x = 3; x<maxImages-1;x++){
// println("should spread them right here "+ x);
// image (gifs[x],x*10,350);
}
router = 3;
}
println("router= "+ router);
if (router == 3){
println("setting up images");
router = 4;
// println("router = "+router);
setupImages();
// background(0);
}
if (router == 4){
// background(255);
for(int i = 3; i < maxImages-2; i++){
calcImagePos(i);
displayImages(i);
// background(0);
// println("this is the value for i");
}
}
}
void movieEvent(Movie m){
m.read();
if (ii > maxImages-3)
{
println("The movie has stopped.");
router = 2;
println("router (in movieEvent) = "+router);
// ii=frameCount;
// color(255);
//draw();
// movie.stop();
// println("The movie has stopped.");
}
ii=frameCount;
println("FRAMECOUNT= "+frameCount);
println("load gifs[]");
gifs[ii]=m.get(0,0,m.width,m.height);
//image(gifs[ii],460,0);
r=ii;
if (r>1){
r = int (random(0,ii));
// println("THIS IS THE VALUDE OF R"+ r);
if (gifs[r] == null)
{
//checks to see whether the value is null before attempting to print to screen
// println(r+ "<---index for gifs with the value for r = null");
}
else{
//println("should print to screen right here");
// image(gifs[r],0,370);
}
}
}