Willkommen auf unserem Seminar-Blog

Immer auf dem aktuellen Stand bleiben

Dieser Seminar-Blog befindet sich noch im Aufbau und wird in den kommenden Tagen entsprechend verfeinert.

Member Login

Lost your password?

Registration is closed

Sorry, you are not allowed to register by yourself on this site!

You must either be invited by one of our team member or request an invitation by email at viad.info {at} zhdk {dot} ch.

motion tracking “Matrix”

März 5, 2012


import processing.video.*;
int W = 640;
int H = 480;

color pColor;
Capture cam;

int res = 4;
int thresh = 20;

color[] buffer;

void setup()
{
 size ( W, H );
 background(0);
 
 buffer = new color[W * H];
 cam = new Capture(this, W, H);
 
}

void captureEvent(Capture cam) 
{
 cam.read();
}

void draw()
{
 sampleAndPaint();
 swapBuffer();
}

void sampleAndPaint()
{
 fill(0, 30);
 rect(0, 0, W, H);
 for ( int i = 0; i < W; i+= res )
 {
   for ( int j = 0; j < H; j+=res )
   {
     int offset = i + j * W;
     color c = cam.pixels[offset];
     color r = buffer[offset];
     
     float cB = brightness(c);
     float rB = brightness(r);
     
     float delta = abs ( cB - rB );
     
     if ( delta > thresh )
     {
       fill ( 0, 255, 0 );
       noStroke();
       //res = int(random(1,res));
       rect ( i, j, res, res );
     }
   }
 }
}
     
void swapBuffer()
{
  
 arrayCopy(cam.pixels, buffer);
}