dancingFlower

Created Date: 2014-12-17/ updated date: 2018-03-13
    Owner & Collaborators
    License
    dancingFlower by risaHiyama is licensed under the Creative Commons - Attribution license.
    Summary
    笑いかけると声を出しながら踊る花を作ります。
    笑いかけを判定するのにfaceOSCを使います。

    Memo

    smileDetector

    posted by risaHiyama on December 17, 2014
    できたこと
    ①faceOSCが顔をトラックしているかを確かめる為に絵を書いた。
    ②笑顔判定機能:笑うとチークが現れる
    ③笑うとLEDがチカっとする

    TO DO 
    ①バイオメタルの可能性を考える⇒NO
    http://shokai.org/blog/archives/4182
    ②花を買う
    ③透明な糸で繋げる
    ④サーボを動かす

    //Risa Hiyama 
    //Project 01 
    //Game discription : Eat the fruit to win!
    //You will need a FaceOSC to function this game


    // a template for receiving face tracking osc messages from
    // Kyle McDonald's FaceOSC https://github.com/kylemcdonald/ofxFaceTracker
    //
    // 2012 Dan Wilcox danomatika.com
    // for the IACD Spring 2012 class at the CMU School of Art
    //
    // adapted from from Greg Borenstein's 2011 example
    // http://www.gregborenstein.com/
    // https://gist.github.com/1603230


    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() {
      //setting up general rule 
      size(640, 480);
      noCursor();
      frameRate(30);
      textSize( 24 );
      
      //faceOSC function
      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() {  
        //start the game 
          stroke(0);
          background(255);
          drawFace();
          if ( mouthWidth >14 ){
            fill(255,192-mouthWidth,203-mouthWidth);
            ellipse(posePosition.x-80, posePosition.y+eyeLeft * -13, 50, 40);
            ellipse(posePosition.x+80, posePosition.y+eyeRight * -13, 50, 40);
           }
    }

    void drawFace(){
      if(found > 0) {
        
        //translate(posePosition.x, posePosition.y);
        //scale(poseScale);    
        
        noFill();
        ellipse(posePosition.x, posePosition.y - 80, 290, 290);
        ellipse(posePosition.x-60, posePosition.y+eyeLeft * -27, 40, 21);
        ellipse(posePosition.x+60, posePosition.y+eyeRight * -27, 40, 21);
        noFill();
        ellipse(posePosition.x, posePosition.y+10, mouthWidth* 9, mouthHeight * 9);
        ellipse(posePosition.x-15, posePosition.y+nostrils * - 6, 15, 9);
        ellipse(posePosition.x+15, posePosition.y+nostrils * - 6, 15, 9);
        rectMode(CENTER);
        fill(0);
        rect(posePosition.x-60, posePosition.y+eyebrowLeft * -15, 75, 15);
        rect(posePosition.x+60, posePosition.y+eyebrowRight * -15, 75, 15);
        
      }
    }

    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) {
      if(m.isPlugged() == false) {
        println("UNPLUGGED: " + m);
      }
    }

    Comments