The Plan

VirtualBoyMe  VirtualBoyMe

Thinking of my next tinker with video capture I remembered the work I had done with image comparison and wondered what would happen if I used live video feeds instead of images. The results were quiet interesting and I just so happened to choose red as my colour to define the changing pixels which reminded me a-lot of the Virtual Gameboy which seemed a bit weird seeing as my last project was recreating images as if they were from a Gameboy so I decided to run with it.

The Result

I was really happy with the result, it wasn’t as clear cut or defined as the Virtual boy, but the effect is very similar. I think for my next project I may try and recreate the SNES look… Seeing as though a theme is forming!

The Instructions

  • Spacebar to capture frames
  • Q to export your gif animation

The Download

mac

The Code

[codesyntax lang=”php”]

import processing.video.*;

PImage imageOne;
PImage imageTwo;

Capture camera;
int pixelYPosition;
int pixelXPosition;

public void setup() {
  saveFrame("imageOne.jpg");
  saveFrame("imageTwo.jpg");
  size (288, 288);

  imageOne = new PImage(width, height);
  imageTwo = new PImage(width, height);
  camera = new Capture(this, width, height, 30);
  camera.start();
  selectFolder("Export Location:", "folderSelected");
}

public void draw() {
  loadPixels();

  if (camera.available()) {
    camera.read();
    camera.filter(THRESHOLD, 0.3);
    image(camera, 0, 0);
    saveFrame("imageOne.jpg");
    saveFrame("imageTwo.jpg");
  }

  loadPixels();
  imageOne = loadImage("imageOne.jpg");
  imageOne.loadPixels();

  for (pixelYPosition = 0; pixelYPosition < imageOne.height; pixelYPosition++) {
    for (pixelXPosition = 0; pixelXPosition < imageOne.width; pixelXPosition++) {
      //
      int loc = pixelXPosition + pixelYPosition * imageOne.width;
      int loc1 = pixelXPosition + pixelYPosition * imageTwo.width;
      //
      float r = red(imageOne.pixels[loc]);
      float g = green(imageOne.pixels[loc]);
      float b = blue(imageOne.pixels[loc]);
      //
      float r1 = red(imageTwo.pixels[loc1]);
      float g1 = red(imageTwo.pixels[loc1]);
      float b1 = red(imageTwo.pixels[loc1]);
      if (r==r1 && g == g1 && b == b1) {
        r = 155;
        g = 0;
        b = 0;
      } else {
        r = 0;
        g = 0;
        b = 0;
      }
      pixels[loc] = color(r, g, b);
    }
  }
  updatePixels();
}
[/codesyntax]