SignalProcessing-Tutorial1/Camerafeed/Camerafeed.pde

39 lines
639 B
Plaintext

import processing.video.*;
Capture cam;
int x =0;
int d = 25;
int eyeZone = 10;
float s = 1/5;
int start = 0;
void setup() {
size(750, 480);
cam = new Capture(this, width, height);
cam.start();
loop();
x=0;
}
void draw() {
if(cam.available()) {
cam.read();
}
image(cam, 0, 0);
if(x<20 && start==1){
saveFrame("frame_#####.jpg");
x++;
}
delay( int(s*1000) );
//fill(255,0,0);
rect(width*0.5-d*2-eyeZone/2,height*0.5,eyeZone,5);
rect(width*0.5+d*2-eyeZone/2,height*0.5,eyeZone,5);
fill(0,0);
rect(width*0.5-3*d/2,height*0.5-d*5/2,3*d,3*d/2);
}
void keyPressed() {
start = 1;
println("ok");
}