I basically want to run a video through this Code. (See below)
The idea is, to extract all the frames, run each through the script and render them back together to a Video file. So far so good.
My Video is 60sec long @ 25 Fps , I end up with 1500 frames. I Want the rendered video to rotate 360° over its duration ( 60sec)
Therefore each Frame has to rotate 0.24°
Since I don’t want to alter the Code each Frame by hand, I need an automation, that loads a Frame, (Image) runs it trough the code, saves it to the output folder, loads a new Frame, rotates it with added 0.24° in comparison to the last frame, saves it… and again and again.
I am very new to Processing and struggling a lot, trying to implement such wished automation in my code, ended in destroying the complete structure of my code…
Luckily I saved a Copy of my “blank” Code ( original found at http://formandcode.com/code-examples/transform-landscape)
Could someone please help me, to structure the wished automation ?
import processing.opengl.*;
PImage img;
int[][] values;
float angle;
void setup() {
size(1920, 1080, OPENGL);
noFill();
values = new int[width][height];
img = loadImage(".jpg");
img.loadPixels();
for (int i = 0; i < img.height; i++) {
for (int j = 0; j < img.width; j++) {
color pixel = img.pixels[i*img.width + j];
values[j][i] = int(brightness(pixel));
}
}
}
void draw() {
background(0); // Set black background
translate(width/2, height/2, 0); // Move to the center
scale(1); // Scale to 400%
// Update the angle
angle += 0.001;
rotateY(angle);
// Display the image mass
for (int i = 0; i < img.height; i += 2) {
for (int j = 0; j < img.width; j += 2) {
stroke(values[j][i], 153);
float x1 = j-img.width/1.75;
float y1 = i-img.height/1.75;
float z1 = -values[j][i]/1.75;
float x2 = j-img.width/1.75;
float y2 = i-img.height/1.75;
float z2 = -values[j][i]/3.5-5.25;
line(x1, y1, z1, x2, y2, z2);
}
}
}