Face Tracking and Data Viz

This sketch must be run with FaceOSC

import oscP5.*;
OscP5 oscP5;

// num faces found
int found;

// gesture
float eyeLeft;

float newEye;
float xPos= 30;
float yPos = 30; 

void setup() {
  size(900, 480);
  frameRate(3);
  background(255);

  oscP5 = new OscP5(this, 8338);
  oscP5.plug(this, "found", "/found");
  oscP5.plug(this, "eyeLeftReceived", "/gesture/eye/left");

  fill(0);
}

void draw() {  
  if(found > 0) {
    newEye = map(eyeLeft, 2, 3, 0, 30);
    ellipse(xPos, yPos , newEye, newEye);
    xPos = xPos + 50;
    if(xPos > (width - 20)){
      yPos = yPos + 100;
      xPos = 20;
    }
    if(yPos > (height - 20)){
      yPos = 100;
      background(255);
    }

  }
}

// OSC CALLBACK FUNCTIONS

public void found(int i) {
  println("found: " + i);
  found = i;
}

public void eyeLeftReceived(float f) {
  println("eye left: " + f);
  eyeLeft = f;
}

// all other OSC messages end up here
void oscEvent(OscMessage m) {
  if(m.isPlugged() == false) {
    println("UNPLUGGED: " + m);
  }
}