All pastes #524382 Raw Edit

Something

public java v1 · immutable
#524382 ·published 2007-05-31 01:59 UTC
rendered paste body
import processing.opengl.*;import toxi.video.capture.*;String CAPTURE_DEVICE = "v4l:Logitech QuickCam USB:0";int CAPTURE_WIDTH = 160;int CAPTURE_HEIGHT = 120;float w_ratio, h_ratio;SimpleCapture capture;LibCV libcv;ArrayList points;void setup(){  frameRate(15);  if(capture == null && libcv == null)  {    capture = new JMFSimpleCapture();    if(!capture.initVideo(CAPTURE_DEVICE, CAPTURE_WIDTH, CAPTURE_HEIGHT, 0))    {      println(capture.getError());      System.exit(0);    }    libcv = new LibCV(this, capture);  }  size(640, 480, OPENGL); // for some reason it has to be after    points = new ArrayList();    w_ratio = width/CAPTURE_WIDTH;  h_ratio = height/CAPTURE_HEIGHT;}void draw(){  background(0);  PImage frame = libcv.getFrame();  image(frame, 0, 0, width, height);      int[] coords = xy_from_i(brightPoint(frame.pixels), CAPTURE_WIDTH);    fill(0, 0, 255);  noStroke();  ellipse(coords[0]*w_ratio, coords[1]*h_ratio, 10, 10);  if(keyPressed && key == ' ')    points.add(new Point(int(coords[0]*w_ratio), int(coords[1]*h_ratio)));    noFill();  stroke(255);  beginShape();  for(int i = 0; i < points.size(); i++)  {    Point p = (Point) points.get(i);    vertex(p.x, p.y);  }  endShape();}public void stop(){  libcv.stop();  super.stop();}