3dpixelcam processing 3d pixels from live video

this isn’t even full size!

Many years ago, I wrote a processing sketch to take live video and generate a 3d pixel grid, varying the height of each 3d box based on the brightness of the video pixel it was sampling. And it was good. Times have changed, and so has processing. Now it’s easier to do what I was doing then in regards to accessing the video input and controlling the 3d camera in the sketch.  There aren’t as many bells and whistles on this version as the original, but hey, it works today.

As such, you will need JMyron and Peasycam to run this sketch.

 

/*
* 3dPixelcam
* steve cooley
* http://beatseqr.com
* license for use: creative commons non-commercial attribution share-alike
* Do Not Omit This Information From Whatever You Make With It. Thanks! -steve
*/
import processing.opengl.*;
import peasy.*;
import JMyron.*;
PeasyCam cam; // a virtual, 3d camera control
JMyron m;//a physical, actual camera object
int resolution = 20;
void setup(){
size(640,480, OPENGL);
cam = new PeasyCam(this, 320.0, 240.0, 100.0, 500);
cam.setMinimumDistance(50);
cam.setMaximumDistance(2000);
m = new JMyron();//make a new instance of the object
m.start(width,height);//start a capture at 320×240
m.findGlobs(0);//disable the intelligence to speed up frame rate
println("Myron" + m.version());
rectMode(CENTER);
noStroke();
}
void draw(){
background(255);
lights();
m.update();//update the camera view
int[] img = m.image(); //get the normal image of the camera
float r,g,b;
for(int y=0;y<height;y+=resolution){ //loop through all the pixels 
 for(int x=0;x<width;x+=resolution){ //loop through all the pixels
float av = (red(img[y*width+x])+green(img[y*width+x])+blue(img[y*width+x]))/3.0;
fill(red(img[y*width+x]),green(img[y*width+x]),blue(img[y*width+x]));
pushMatrix();
translate(x,y);
//ellipse(0,0,(255-av)/8.0,(255-av)/8.0);
box(resolution,resolution,(av));
popMatrix();
}
}
}
void keyPressed(){
// m.settings();//click the window to get the settings
resolution -= 2;
if(resolution <=1)
{
resolution = 40;
}
}
public void stop(){
m.stop();//stop the object
super.stop();
}

2013-03-12 Updated to fix wp code manglation