2012.11.15

Simple Photobooth

If you saw my old post about a simplistic photo booth using Processing, you probably loved it so much that you used it, and you probably loved using Processing so much that you used that too, and you even installed the betas of Processing 2.0, and then you cursed out loud as the code no longer worked.

Calm down, sport… we’re here to help.

While not final yet, Processing 2.0 has a lot of changes compared to Processing 1.5.x, and those of us who dabble in writing sketches can expect some breakage, but we can also attempt some fixage.

Here’s what I’ve got now… which works for me! (YMMV)

/**
 * PhotoBoothV2.pde
 */
 
import processing.video.*;

// resolution: 800x600 - change it if you want
int cols = 800;
int rows = 600; 

Capture cam;

int mainwidth  = cols;
int mainheight = rows;

void setup() {
  frameRate(30);
  size(mainwidth, mainheight, JAVA2D);
  colorMode(RGB);
  cam = new Capture(this, cols, rows); 
  cam.start(); 
  noSmooth();
  background(0);
}

void draw() {
  if (cam.available()) {
    cam.read();
    image(cam, 0, 0);
  }
} 

void keyPressed() {
    if (key == ' ') {  // space bar
       saveFrame("picture-####.jpg");
    }
}

Boom! You got a simplistic photo booth application. Congratulate yourself by purchasing this lovely button for it. (Or get this “bare” button and build your own damn case.)

Also, special thanks to Evil Mad Scientist for releasing their Atkinson Dithering sketch, which reminded me I had to fix my Processing code, and provided some hints on what needed updating.

Comments are closed.

« | »


buy the button:

Buy The Button