Chicken Cam

Presentation

Paper:link

Prototype

Control Code

written with Processing
import processing.video.*;


Capture video1;
Capture video2;
int numPixels;
boolean video1_on_top;
int clucktime; //when was the last camera switch
int count; //frame counter

void setup() {
  size(320, 240); 
  video1 = new Capture(this, 320, 240, 24);
  video2 = new Capture(this, 320, 240, 24);
  numPixels = video1.width * video1.height;
  
  // Create an array to store the previously captured frame
  loadPixels();
  video1_on_top = true;
  frame = new float[numPixels];
  clucktime=0;
  count = 0;
}


void draw() {
  if (video1.available()) {
    count++;
    
    video1.read(); // Read the new frame from camera1
    video1.loadPixels(); // Make its pixels[] array available
    video2.read(); // Read the new frame from the camera2
    video2.loadPixels(); // Make its pixels[] array available
    
    int a1 = 0;
    int a2 = 0;
    for (int i=0;i<numPixels;i++){
      a1+=avg(video1.pixels[i])/10;
      a2+=avg(video2.pixels[i])/10;
    }
    clucktime++;
    if (a1>a2){
      if (!video1_on_top && clucktime>30){
        print("1");  
        clucktime=0;
      }
      video1_on_top = true;
      for (int i=0;i<numPixels;i++){
        pixels[i] = video1.pixels[i];
      }
    } else {
      if (video1_on_top && clucktime>30) {
        print("2");
        clucktime = 0;
      }
        video1_on_top = false;
      for (int i=0;i<numPixels;i++){
        pixels[i] = video2.pixels[i];
      }
    }

    updatePixels();
    save("saveframe"+count+".jpg");
  }
}

Prototype Results

Moving Camera:

Notice the horizontal blurring
Motion Canceled Camera:

Horizontal blur reduced.
Vertical blur due to belt jitter