import processing.video.*;
int numPixels;
int pixelSize = 20;
//Movie myMovie;
color myMovieColors[];
Capture cam;
void setup() {
  size(1280, 756);
  // If no device is specified, will just use the default.
   cam = new Capture(this, width, height, 30);
  numPixels = height / pixelSize;
  myMovieColors = new color[numPixels * numPixels];
  // To use another device (i.e. if the default device causes an error),  
  // list all available capture devices to the console to find your camera.
  //String[] devices = Capture.list();
  //println(devices);
  // Change devices[0] to the proper index for your camera.
  //cam = new Capture(this, width, height, devices[0]);
  // Opens the settings page for this capture device.
  //camera.settings();
}
void captureEvent(Capture cam) {
  cam.read();
  cam.loadPixels();
  for (int j = 0; j <>
    for (int i = 0; i <>
      myMovieColors[j*numPixels + i] = cam.get(i, j);
    }
  }
}
void draw() {
  //if (cam.available() == true) {
    //cam.read();
    //image(cam,160, 100);
    // The following does the same, and is faster when just drawing the image
    // without any additional resizing, transformations, or tint.
    //set(160, 100, cam);
     for (int j = 0; j <>
This takes the live stream from a video camera, and uses this to plot rectangles which reflect the colours of the stream.
Russell
    for (int i = 0; i <>
      float r = random(-10,10);
      fill(myMovieColors[j*numPixels + i]);
      smooth();
      rect(i*(r*pixelSize), j*(r*pixelSize), pixelSize+5, pixelSize+5);
    }
   }
  } 
This takes the live stream from a video camera, and uses this to plot rectangles which reflect the colours of the stream.
Russell
No comments:
Post a Comment