Frame Differencing






Basic movement detection via frame differencing algorithm.



I'm a little peeved at the absence of the 'Fused Media and Applications' module from this years curriculum. From what I can gather, the module covered OpenCV and OpenGL which are the two main API's I'm using for the application pictured above. Well, looks like I'll have to go it alone this year.

Processing

Processing (http://processing.org) is incredibly easy as programing languges go. The sketch below took five minutes to write and debug.

import processing.opengl.*;
float angle1=0.1;
float fillCol=0.0;

void setup(){
size(600,400,OPENGL);
//noStroke();

}

void draw(){
background(100);
//lights();
pointLight(256, 256, 256, fillCol, 200, 36);
translate(300,200,-100);

for (int i=0;i<80;i++){
pushMatrix();
rotateY(sin(radians(fillCol))*-i);
rotateX(cos(radians(angle1))*-fillCol);
rotateZ(sin(radians(angle1))*-i);
translate((2*i),2*i,2*1);
box(i,i,20+i);
//fill(10+(i*2));
fill(i*2+50);
popMatrix();
}

angle1+=.15;
}

void mouseDragged(){
fillCol=fillCol+0.1;
}

Fast inverse square root

float InvSqrt (float x){
float xhalf = 0.5f*x;
int i = *(int*)&x;
i = 0x5f3759df - (i>>1);
x = *(float*)&i;
x = x*(1.5f - xhalf*x*x);
return x;
}


Terribly quick (if less accurate) newton-raphson iteration. Handy for vector normalization, etc. Big thanks to Carmack et al.