Processing Blinds
Another oldish sketch I dug up. The idea was to project it onto a store window, and then a passerby would need to pull open the blinds to see in the store.
It used to be quite processor heavy, so reworked the motion detection code to try and speed it up. By pre-calculating the grid positions on the screen I managed to achieve a significant speed increase.
UPDATE: Just noticed some other places where code can be speeded up. Will update the code when I get time.
View the sketch here.
Here’s the motion detection part of the code:
import processing.video.*;
Capture myCapture;
color newPixel;
color[] prevFrame;
float speed = 10;
float sensitivity = 0.64;
float targetX, targetY, myX, myY, avX, avY;
int cxLoc, cyLoc;
int counter=0;
int totalBlocks=0;
int[] cX= new int[5000];
int[] cY= new int[5000];
// precalculating the grib
void precalc(){
for(int y = 0; y < 30-1; y++){
for(int x = 0; x < 40-1; x++){
cX[counter] = x*(width/40);
cY[counter] = y*(height/30);
counter++ ;
}
}
totalBlocks=counter;
}
void initVid () {
String s = "IIDC FireWire Video";
myCapture = new Capture ( this, width, height, 4);
prevFrame = new color[width*height];
}
void captureEvent ( Capture myCapture ) {
myCapture.read();
}
void motion () {
avX = 0;
avY = 0;
counter = 0;
for(int i = 0; i < totalBlocks; i++){
if(motionTest(i,width/40,height/30)==true){
avX += cX[i];
avY += cY[i];
counter ++;
}
}
if (avY<=0) avY=myY;
if (avX<=0) avX=targetX;
if (avY>0 && avX>0 && counter>0){
targetX=width-avX/counter;
targetY=avY/counter;
}
myY += (targetY-myY)/speed;
myX += (targetX-myX)/speed;
}
boolean motionTest(int j,int tw, int th){
int dc=0; // counter to track number of differences
//print(j);
// ave. out a square
for(int y=0;y
for(int x=0;x
int srcPos=((cY[j]+y)*width)+(cX[j]+x);
// int srcPos=cY[j]*(width)+cX[j];
newPixel = myCapture.pixels[srcPos];
if(abs(red(newPixel)-red(prevFrame[srcPos]))>25) dc++;
prevFrame[srcPos]=newPixel; // update prevFrame w/ current pixel clr
}
}
if(dc>(sensitivity*(tw*th))){ return true; } else{ return false; }
}
Also of interest:
Reactive Video: Peter Saville Tribute3D Pixels
White Void
Radarboy Reaktiv at Apple Store Tokyo
Motion Tracking 80s stylee
How much is that doggy in the window?
Magnetic Ink
Vines
Daniel Rozen’s Weave Mirror
Radarboy Reactive
Most Popular Posts:
King of Africa: King's CarMorseTweet Beta Released
Lori Hersberger
Solving Rubik's Cube with Lego
Radarboy Reaktiv at Apple Store Tokyo
Tale Of The Tape
Marti Guixe Sculpt Me Point
The masterplan
24 locations in 24 hours / NYC
Magnetic Ink
You can leave a response, or trackback from your own site.
