Pixel me in, Part 2

Super Duper fast but here is some of what I was trying to go for with the pix-elated live feed video footage in Processing. And I owe this to Peter who suggested I move the sequence with which the events occurred within the code. See the code below the video. Still not quite what I would like but that’s it for now…

Code:

import processing.video.*; // Step 1. Import the video library
int cellsize = 5; // Dimensions of each cell in the grid
int cols, rows;   // Number of columns and rows in our system
Capture video; // Step 2. Declare a Capture object
MovieMaker mm;  // Declare MovieMaker object
void setup() {
size(640,400,P3D);
// Step 3. Initialize Capture object via Constructor
// video is 320 x 240, @15 fps
video = new Capture(this,640,400,24);
cols = width/cellsize;              // Calculate # of columns
rows = height/cellsize;             // Calculate # of rows
// create movie maker object with size, filename
// compression codec and quality, framerate
mm = new MovieMaker(this, width, height, “my pixel video.mov”,
30, MovieMaker.H263, MovieMaker.HIGH);
}
void draw() {
background(255);
// Check to see if a new frame is available
if (video.available()) {
// If so, Step 4. Read the image from the camera.
video.read();
}
// if (mouseX < width/2 && mouseY < height/2){
// tint(10,200,200);
//  }
if (mouseX > width/2 && mouseY > height/2) {
tint(255,0,0);
}
// Step 5. Display the video image.
image(video,0,0);
mm.addFrame();  // Add window’s pixels to movie
// Begin loop for columns
for (int i = 0; i < cols; i++ ) {
// Begin loop for rows
for (int j = 0; j < rows; j++ ) {
int x = i*cellsize + cellsize/2; // x position
int y = j*cellsize + cellsize/2; // y position
int loc = x + y*width;           // Pixel array location
color c = video.pixels[loc];       // Grab the color
// Calculate a z position as a function of mouseX and pixel brightness
float z = (mouseX/(float)width) * brightness(video.pixels[loc])- 50.0;
// Translate to the location, set fill and stroke, and draw the rect
pushMatrix();
translate(x,y,z);
fill(c);
noStroke();
rectMode(CENTER);
rect(0,0,cellsize*2,cellsize*2);
popMatrix();
}
}
mm.addFrame();  // Add window’s pixels to movie
}
void keyPressed() {
if (key == ‘ ‘) {
mm.finish();  // Finish the movie if space bar is pressed!
}
}
// stops video live feed
void mousePressed() {
video.stop();
}

import processing.video.*; // Step 1. Import the video libraryint cellsize = 5; // Dimensions of each cell in the gridint cols, rows;   // Number of columns and rows in our system
Capture video; // Step 2. Declare a Capture object
MovieMaker mm;  // Declare MovieMaker object
void setup() {  size(640,400,P3D);
// Step 3. Initialize Capture object via Constructor  // video is 320 x 240, @15 fps  video = new Capture(this,640,400,24);
cols = width/cellsize;              // Calculate # of columns  rows = height/cellsize;             // Calculate # of rows
// create movie maker object with size, filename  // compression codec and quality, framerate  mm = new MovieMaker(this, width, height, “my pixel video.mov”,  30, MovieMaker.H263, MovieMaker.HIGH);}
void draw() {  background(255);  // Check to see if a new frame is available  if (video.available()) {    // If so, Step 4. Read the image from the camera.    video.read();  }
// if (mouseX < width/2 && mouseY < height/2){
// tint(10,200,200);
//  }
if (mouseX > width/2 && mouseY > height/2) {
tint(255,0,0);  }
// Step 5. Display the video image.  image(video,0,0);
mm.addFrame();  // Add window’s pixels to movie
// Begin loop for columns  for (int i = 0; i < cols; i++ ) {    // Begin loop for rows    for (int j = 0; j < rows; j++ ) {      int x = i*cellsize + cellsize/2; // x position      int y = j*cellsize + cellsize/2; // y position      int loc = x + y*width;           // Pixel array location      color c = video.pixels[loc];       // Grab the color
// Calculate a z position as a function of mouseX and pixel brightness      float z = (mouseX/(float)width) * brightness(video.pixels[loc])- 50.0;
// Translate to the location, set fill and stroke, and draw the rect      pushMatrix();      translate(x,y,z);       fill(c);      noStroke();      rectMode(CENTER);      rect(0,0,cellsize*2,cellsize*2);      popMatrix();    }  }
mm.addFrame();  // Add window’s pixels to movie}
void keyPressed() {  if (key == ‘ ‘) {    mm.finish();  // Finish the movie if space bar is pressed!  }}
// stops video live feedvoid mousePressed() {  video.stop();}

About Michell-Johanna-Cardona