fidgity

For this assignment, I found something very endearing about the motion tracker and its interaction with primitives. While quite simple, I had fun watching these tiny shapes nervously twitch to the movement of my face.

import oscP5.*;
OscP5 oscP5;

// num faces found
int found;

// pose
float poseScale;
PVector posePosition = new PVector();
PVector poseOrientation = new PVector();

// gesture
float mouthHeight;
float mouthWidth;
float eyeLeft;
float eyeRight;
float eyebrowLeft;
float eyebrowRight;
float jaw;
float nostrils;

void setup() {
  size(640, 480);
  frameRate(30);
 

  oscP5 = new OscP5(this, 8338);
  oscP5.plug(this, "found", "/found");
  oscP5.plug(this, "poseScale", "/pose/scale");
  oscP5.plug(this, "posePosition", "/pose/position");
  oscP5.plug(this, "poseOrientation", "/pose/orientation");
  oscP5.plug(this, "mouthWidthReceived", "/gesture/mouth/width");
  oscP5.plug(this, "mouthHeightReceived", "/gesture/mouth/height");
  oscP5.plug(this, "eyeLeftReceived", "/gesture/eye/left");
  oscP5.plug(this, "eyeRightReceived", "/gesture/eye/right");
  oscP5.plug(this, "eyebrowLeftReceived", "/gesture/eyebrow/left");
  oscP5.plug(this, "eyebrowRightReceived", "/gesture/eyebrow/right");
  oscP5.plug(this, "jawReceived", "/gesture/jaw");
  oscP5.plug(this, "nostrilsReceived", "/gesture/nostrils");
}

void draw() {  
  
  
  background(149,186,177);
  
  
  
  if(found > 0) {
    translate(posePosition.x, posePosition.y);
    scale(poseScale);
    stroke (191, 222, 215);
    strokeWeight (1);
  
   
    for (int i=5; i< 30; i+=70){
      fill (216, 242, 236);
    ellipse (i, nostrils, 5, 5);
    }
    
    line (20, eyebrowLeft, 1, 10);
    line (21, eyebrowRight, 1, 10);
    line (22, eyebrowLeft, 1, 10);
    line (23, eyebrowRight, 1, 10);
    line (eyebrowLeft, 23, 1, 10);
    
    stroke (216, 242, 236);
    noFill ();
    ellipse (jaw, 100, 2, 2);
    ellipse (jaw, 30, 4, 4);
    ellipse (45, jaw, 2, 2);
    
    line (eyebrowLeft, 10, 25,50);
    line (10,eyebrowRight, 25, 50); 
    
    line (eyebrowLeft, eyebrowRight, 5, 70);
    ellipse (eyebrowLeft*2, 60, 1, 1);
    ellipse (eyebrowLeft*2, 10, 1, 1);
    stroke (191, 222, 215);
    ellipse (eyebrowRight, 55, 1, 1);
    ellipse (eyebrowRight, 10, 1, 1);
    
    stroke (224, 213, 216);
    ellipse (mouthHeight/height, 5, 1, 1);
    ellipse (mouthWidth/height, 1, 1, 1);
    ellipse (40, mouthHeight, 3, 3);
    

   
      }
    }
    


// OSC CALLBACK FUNCTIONS

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

public void poseScale(float s) {
  println("scale: " + s);
  poseScale = s;
}

public void posePosition(float x, float y) {
  println("pose position\tX: " + x + " Y: " + y );
  posePosition.set(x, y, 0);
}

public void poseOrientation(float x, float y, float z) {
  println("pose orientation\tX: " + x + " Y: " + y + " Z: " + z);
  poseOrientation.set(x, y, z);
}

public void mouthWidthReceived(float w) {
  println("mouth Width: " + w);
  mouthWidth = w;
}

public void mouthHeightReceived(float h) {
  println("mouth height: " + h);
  mouthHeight = h;
}

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

public void eyeRightReceived(float f) {
  println("eye right: " + f);
  eyeRight = f;
}

public void eyebrowLeftReceived(float f) {
  println("eyebrow left: " + f);
  eyebrowLeft = f;
}

public void eyebrowRightReceived(float f) {
  println("eyebrow right: " + f);
  eyebrowRight = f;
}

public void jawReceived(float f) {
  println("jaw: " + f);
  jaw = f;
}

public void nostrilsReceived(float f) {
  println("nostrils: " + f);
  nostrils = f;
}

// all other OSC messages end up here
void oscEvent(OscMessage m) {

/* print the address pattern and the typetag of the received OscMessage */
println(“#received an osc message”);
println(“Complete message: “+m);
println(” addrpattern: “+m.addrPattern());
println(” typetag: “+m.typetag());
println(” arguments: “+m.arguments()[0].toString());

if(m.isPlugged() == false) {
println(“UNPLUGGED: ” + m);
}
}

Comments are closed.