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
Projected fashion onto semi-naked girls
Most Popular Posts:
Going pottyEbon Heath
Marti Guixe Sculpt Me Point
King of Africa: King's Car
David Shrigley whimsical illustrations and photograph's
MorseTweet Beta Released
Lori Hersberger
Digital Zoo
Erwin Redl LED Art
Peter Freeman's Traveling Light
You can leave a response, or trackback from your own site.
