AsciiVisualiser1 AsciiVisualiser

The Plan

In an attempt to make a fake QR visualiser I started thinking if I could export the pixels as 0’s and 1’s to generate a unique URL So naturally I started thinking about a way to generate this output. My thought was to convert the image to black and white, make the blacks 1 and whites 0 which is what I did.

At which point the output of the video was an image vaguely visible and at which point I though ASCII art! So the plan changed slightly to make a poor mans ASCII art visualier!

The Result

I thought the output looked good, but if you compared it with a real ASCII art image you would notice straight away the lack of varying characters in my images and that was true because I simply converted the pixel colours either ‘255’ or ‘o’ to a”#” and “.@.”. I could have, if I was serious about taking this to the next level (which I wasn’t) start thinking about ways to add extra details. But anyhow, it worked fine the way it was and the result were good enough for my liking.

It can be hard to see the image, so squinting the eyes helps!

The Instructions

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

The Download

mac

 

The Code

[codesyntax lang=”php”]

import processing.video.*;

int cameraScale = 9;
int columns;
int rows;
Capture camera;

void setup() {
  size(288, 280);
  columns = width/cameraScale;
  rows = height/cameraScale+1;
  camera = new Capture(this, columns, rows, 30);
   selectFolder("Export Location:", "folderSelected");
}

void draw() {

  camera.start();
  background(255);
  if (camera.available()) {
    camera.read();
  }
  camera.loadPixels();
  camera.filter(THRESHOLD, 0.5);

  for (int column = 0; column < columns; column++) {
    for (int row = 0; row < rows; row++) {
      int x = column*cameraScale;
      int y = row*cameraScale;
      float r = red(camera.pixels[column + row*camera.width]);
      float g = green(camera.pixels[column + row*camera.width]);
      float b = blue(camera.pixels[column + row*camera.width]);
      noStroke();

      if (r <=120 && g <=120 && b<=120) {
        text(".@.", x, y);
        fill(0);
      } else  if (r >120 && g>120 && b>120) {
        text(" # ", x, y);
        fill(0);
      }
    }
  }
}

void keyPressed() {
  if (key == ' ') {
    saveImage();
  }
  if (key == 'q') {
    createAnimation();
  }
}

[/codesyntax]