Skip to content

Instantly share code, notes, and snippets.

@sport4minus
Created June 23, 2012 13:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sport4minus/2978360 to your computer and use it in GitHub Desktop.
Save sport4minus/2978360 to your computer and use it in GitHub Desktop.
load image sequence in processing
/**
* this code snippet can be used in the processing environment to load all images in a folder
* "input" in the sketches' data folder into an array of PImages.
* ideally, the images are sequentially named, like 0001.jpg, 0002.jpg etc.
* in this demo, te images are sequentially displayed.
*/
PImage[] imageSequence;
String[] imageFilenames;
void setup() {
size(800, 600);
//Java's File Class is used to navigate the file system
File inputDirectory = new File(dataPath("input"));
//ignore invisible files (osx, linux)
FilenameFilter filter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return !name.startsWith(".");
}
};
imageFilenames = inputDirectory.list(filter);
imageSequence = new PImage[imageFilenames.length];
for (int i = 0; i < imageFilenames.length; i++) {
imageSequence[i] = loadImage("input"+File.separator+imageFilenames[i]);
}
}
void draw() {
image(imageSequence[frameCount%imageSequence.length], 0, 0, width, height);
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment