Skip to content

Instantly share code, notes, and snippets.

@danpaluska
Created March 14, 2012 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danpaluska/2040376 to your computer and use it in GitHub Desktop.
Save danpaluska/2040376 to your computer and use it in GitHub Desktop.
simple timelapse capture program for processing, writes images to sketch folder
/** simple Timelapse campture
* Public domain 2012
* a basic merge and slight alteration of a couple processing examples
*/
import processing.video.*;
Capture cam;
float numFrames = 1050;
int last=0;
int saveCounter=1000; // start with 1000 so always in order for import into movie making
int delayMillis=5000; //framedelay in milliseconds, U EDIT THIS to change timelapse
void setup() {
size(640, 480);
// If no device is specified, will just use the default.
cam = new Capture(this, 640, 480); //you might need to change resolution
// To use another device (i.e. if the default device causes an error),
// list all available capture devices to the console to find your camera.
//String[] devices = Capture.list();
//println(devices);
// Change devices[0] to the proper index for your camera.
//cam = new Capture(this, width, height, devices[0]);
// Opens the settings page for this capture device.
//camera.settings();
last=millis(); // for timing of the shots
}
void draw() {
if (cam.available() == true) {
cam.read();
image(cam, 0, 0);
// The following does the same, and is faster when just drawing the image
// without any additional resizing, transformations, or tint.
//set(160, 100, cam);
}
if ((millis()-last) > delayMillis)
{
//text("timingevent", x, 60);
last=millis();
saveCounter++;
if (saveCounter <= numFrames) {
// text("saveframeevent",x,120);
saveFrame("frame-" + saveCounter + ".tif");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment