Categories: Uncategorized

[Processing]How to use Camera

Outline

Try to develop program which use camera and draw the image to make AR app in the future.

Source Code

The source code is following.
It’s very easy to make it with Processing. How useful!
import processing.video.*;

// Definition camera device interface
Capture cam;

void setup() {
  // Set size
  size(640,480,P3D);
  // Create camera device interface
  cam = new Capture(this, width, height);
}

void draw() {
  // Check whether camera is available
  if (cam.available() == false) return;
  // Get camera image
  cam.read();
  // Draw camera image
  background(0);
  image(cam, 0, 0, width, height);
}

Result

The result is like following.
Of course, actually, the result is movie.

zuqqhi2