Batch processing images to compile into video question
in
Programming Questions
•
2 months ago
Hey all,
I'm new to processing as of a week or two and diving in head first!
I've been experimenting with lots of open source pixel sorting sketches and I'm looking to process a batch of still video frames, in .jpg form, for the purpose of recompilation into video. No luck so far and I was wondering if anyone would be willing to point out the error in my code or in the right direction.
I'm getting a
NullPointerException error at the
for line right after my
void draw() statement
thanks in advance for taking a look!
- import java.util.Date;
- PImage img;
- Date d = new Date();
- long timestamp = d.getTime()/1000;
- File dir = new File(dataPath("images"));
- String[] list = dir.list();
- void setup() {
- size(1080,720);
- }
- void draw() {
- for (int x = 0; x < list.length; x++);{
- img = loadImage("list[x]");
- }
- background(img);
- loadPixels();
- for (int y = 0; y<height; y+=1 ) {
- for (int x = 0; x<width; x+=1) {
- int loc = x + y*img.width;
- float r = red (img.pixels[loc]);
- float g = green (img.pixels[loc]);
- float b = blue (img.pixels[loc]);
- float av = ((r+g+b)/3.0);
- pushMatrix();
- translate(x,y);
- stroke(r,g,b);
- if (r > 30 && r < 255) {
- line(0,0,(av-255)/1,0); //change these values to alter the length. The closer to 0 the longer the lines.
- // goose note: see 255? the number right after that, which should be 1 by default in my copy, is the easiest one to change for line length. try decimals for longer ones!
- // you can also try different shapes or even bezier curves instead of line();
- }
- popMatrix();
- }
- }
- println("done");
- noLoop();
- save("sort"+timestamp+".png");
- }
1