Final Project

For my final project, I created a generative text program that would recognize a face when  a person approached the computer, and then “interact” with you, and dispense a snippet of generated prose.
My original intent was to create a very complex program which would take data from your face, and assign elements of your face to specifics strings of words, but i ended up straying from that entirely, and the result turned into more of a tool, or a way for fresher ideas to be conjured up. The words within the string sets are all words which relate to various other ideas I have been thinking of lately, or things I have been writing. Shuffling up these words allowed me to view them differently, and while this is more of simple program, I am still pleased.
Screen Shot 2014-12-03 at 13.23.15

import oscP5.*;
OscP5 oscP5;

// num faces found
int found;
int stage = 0;

// 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;


 PFont font;

String [] nounbegin = {"morning","we"," you", "i", "you", "we", "i", "stop", "the calling", "hiss", "keep", "ever", "never", "this cannot", "this", "please", "convenience", "bedding", "resting place", "womb", "part", "projections", "interlude", "styrofoam", "night", "lives", "invisible", "fingernails", "fruit", "return", "wet", "vulnerable", "metal", "unknown", "physical", "perpetual", "away", "way", "immesurable", "not found", "always", "exist", "exits", "exit", "think", "distance", "cold", " tepid", "lukewarm", "south", "equation", "difficulty", "tough", "message", "air", "humidity", "touch", "deathwish", "puddle", "sunspots", "wheat", "ration", "disbelief", "never", "you", "sleeping", "number", "mapping", "pressed", "i", "you", "a", "it", "i'll", "paths", "if", "light", "a final", "skin", "they", "curtain", "this horizon", "holes", "a patch", "the wind", "a carpet", "seam", "blaze", "your", "dog", "this", "pitter", "the cusp", "do not", "hue", "eye", "end", "one of", "a space", "afterglow"};
String [] nounnon = {"3:", "vulnerability", "principle,", " forever", "slipped", "credit", "line", "people", "tucked", "away", "find", "36", "wood", "choice", "dwelling", "mama", "knee", "spillage", "slope", "shirts", "seat", "trees", "blanket", "this", "nothing", "gold", "excrement", "windowsill", "bread", "hair", "exchange", "fern", "beings", "blue", "touch", "face", "mechanisms", "me", "mouth", "you", "2008", "core", "room", "awning", "sunspots", "flesh", "streams", "water", "feeling", "it", "text"};
String [] adj = {"zero", "oddly", "elongated", "lucid", "crippled", "slippery", "black", "uneven", "white", "pink", "quaint", "five", "dry", "bright", "off", "crumbly", "soft", "furrowed", "spread", "burrowed", "limp", "jaded", "tumultuous", "tiny", "open", "curled", "multiple", "raw", "still", "strange", "circular", "leaned", "sleeping", "lathed", "blurry", "translucent", "plastic", "babbling", "bug-like", "no", "bleached", "chewed", "closer", "slight", "sun-kissed", "shadowed", "dead", "grassy", "giddy", "bent", "sloppy", "flickering"};
String [] verb = {"return","replace", "gift", "pour", "blame", "trap", "solidify", "obliterate", "concern", "sink", "got", "steaming", "sleepwalking", "breaking", "lengthen", "devour", "swallow", "piece", "fault", "kill", "destroy", "choose", "rain", "shift", "remember", "admit", "lean", "bother", "glint", "glints", "notice","v.s.", "sat", "sentimentalize", "drag", "agree", "sang", "found", "hum"," muddle", "bore", "touch", "go", "repeat", "bear", "is", "asleep", "looming", "curves", "listening", "want", "emulate", "press", "lag", "speak", "know"};
String [] adverb = {"slightly","next", "oddly", "mid","before,", "closely", "guilty", "vehemently", "unexplainable", "after", "far", "fully", "during", "however", "just", "only", "once", "later", "never", "not", "now","right", "from", "less", "watery", "kindly", "numb", "quite", "soon", "so", "subtly", "there", "then", "too", "twice", "tensely", "up", "very", "when", "where", "well", "yet", "over", "tenderly", "softly", "painfully", "slowly", "always", "dewy", "fluorescently", "never", "thickening", "blindly", "deftly", "exactly", "evenly", "finally", "madly" };
String [] other = {"his","above", "about", "during", "is", "her", "amongst", "along", "before", "through", "to", "and", "if", "this", "on", "at", "after", "but", "how", "into", "the", "as", "in"};
String [] punc = {",", ".", "/", "--", ";", ":", ""};
String [] punc2 = {",", "--", ";", ":", " ", "", ""};

String prose = "";


int startTime ;
int currentTime ;


void setup() {
 

  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");
  
  size (1400,1100);
  background (180, 204, 188);
  smooth ();
  fill (255);
  textSize (40);
  textAlign ( CENTER );
  
  
  
  text ("please, come closer", width/2, height/4);
 
  
}


void draw() {  
  currentTime = millis();
  
  if(found > 0) {
    if (stage == 0) { 
      stage = (stage + 1) % 4;
      startTime = millis();
    }
    
    switch(stage) {
      case 1:
         background (180, 204, 188);
         text ("let me get a good look at you", width/2, height/4); // this is initiated after a face is detected
         break;
         // 10 sec delay
      case 2:    
         /// after face is detected and text is said, after a few seconds, a circle will appear on screen 
         // 5 sec delay
         background (180, 204, 188);
         noFill ();
         stroke (255);
         strokeWeight (10);
         ellipse (width/2, height/4, 200, 200);
         
         textSize (55);
         
         if ( ((currentTime - startTime) / 1000) >= 1) {
           prose = nounbegin[int(random(0, nounbegin.length))] +" "+punc2[int(random(0, punc2.length))]+" "+adverb[int(random(0, adverb.length))] +" "+verb[int(random(0, verb.length))] +" "+other[int(random(0, other.length))] +" "+adj[int(random(0,adj.length))]+" "+nounnon[int(random(0, nounnon.length))] +" "+punc[int(random(0, punc.length))]+"\n" +
        (adverb[int(random(0, adverb.length))]+" "+verb[int(random(0, verb.length))]);
         }
         
         break;
      case 3: 
      // 20 sec delay     
        background (180, 204, 188);
        text (prose, width/2, height/4);
         
         
         break;  
         
    }
  } else if (stage == 0) {
    background (180, 204, 188); 
    text ("please, come closer", width/2, height/4); 
  }
  
  if ( ((currentTime - startTime) / 1000) >= 7) {
     stage = (stage + 1) % 4;
     startTime = millis();
  }

}


// 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.