-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimeLapse.pde
62 lines (52 loc) · 1.04 KB
/
TimeLapse.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import ddf.minim.*;
import processing.video.*;
int secs = 150;
Capture cam;
Minim minim;
AudioSample shutter;
long nextPic = 0;
Date date;
long timestamp;
PFont font;
String fileName() {
return "SNAP-"+timestamp+".png";
}
long getTime() {
date = new Date();
return date.getTime()/1000;
}
void setup() {
size(800, 600);
font = loadFont("SansSerif-24.vlw");
textFont(font);
minim = new Minim(this);
cam = new Capture(this, width, height, 15);
shutter = minim.loadSample("data/shutter.wav");
timestamp = getTime();
nextPic = timestamp + secs;
}
void draw() {
if(cam.available()) {
cam.read();
}
image(cam, 0, 0);
timestamp = getTime();
if( timestamp == nextPic ) {
shutter.trigger();
saveFrame(fileName());
background(255,255,255);
delay(200);
nextPic = timestamp + secs;
} else {
fill(0);
rect(8, 7, 60, 25);
fill(255);
textAlign(CENTER);
text( String.valueOf(Math.round(nextPic-timestamp)), 8, 8, 60, 25);
}
}
void stop() {
shutter.close();
minim.stop();
super.stop();
}