Questions to Ponder

Note To Self:

- It is about the viewers interaction with their body and sounds to produce a renewed sense of personal space

Wednesday, December 8, 2010

Code for Brightness Tracking

--

import processing.video.*;

// Size of each cell in the grid
int cellSize = 36;
// Number of columns and rows in our system
int cols, rows;
// Variable for capture device
Capture video;


void setup() {
size(630, 480, P3D);
//set up columns and rows
cols = width / cellSize;
rows = height / cellSize;
colorMode(RGB, 255, 255, 255, 100);
rectMode(CENTER);

// Uses the default video input, see the reference if this causes an error
video = new Capture(this, width, height, 15);

background(0);
}


void draw() {
if (video.available()) {
video.read();
video.loadPixels();

background(0, 0, 255);

// Begin loop for columns
for (int i = 0; i < cols;i++) {
// Begin loop for rows
for (int j = 0; j < rows;j++) {

// Where are we, pixel-wise?
int x = i * cellSize;
int y = j * cellSize;
int loc = (video.width - x - 1) + y*video.width; // Reversing x to mirror
the image

// Each rect is colored white with a size determined by brightness
color c = video.pixels[loc];
float sz = (brightness(c) / 255.0) * cellSize;
fill(255);
noStroke();
rect(x + cellSize/2, y + cellSize/2, sz, sz);
}
}
}
}




--

1 comment:

  1. No way to detect male/female that I can think of. However, check out a friend of mine who recently did her thesis on gesture and gender identity. She was interested in gestures and if gestures could be described as male/female.

    http://susanserafin.com/

    Bryan

    ReplyDelete