Created
July 7, 2014 07:49
-
-
Save ktnyt/ec02e6e71e79294ca13d to your computer and use it in GitHub Desktop.
Press enter to take a picture
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import processing.video.*; | |
Capture camera; | |
PImage picture = null; | |
void setup() { | |
size(640, 480); | |
camera = new Capture(this, 640, 480, 30); | |
camera.start(); | |
} | |
void draw() { | |
if(camera.available() == true) { | |
camera.read(); | |
} | |
if(picture == null) { | |
set(0, 0, camera); | |
} else { | |
set(0, 0, picture); | |
} | |
} | |
void keyPressed() { | |
if(key == ENTER) { | |
if(picture == null) { | |
picture = new PImage(640, 480); | |
for(int i = 0; i < 640; i++) { | |
for(int j = 0; j < 480; j++) { | |
picture.pixels[i + j * 640] = camera.pixels[i + j * 640]; | |
} | |
} | |
} else { | |
picture = null; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment