0

FaceOSCSyphon で Processing を使用しており、Siphon を使用して Processing から VPT にフレームを送信する必要があります。これを機能させるには、コードに何を追加する必要がありますか?

4

1 に答える 1

0

FaceOSCSyphon は使用していませんが、FaceTracker ライブラリで少し遊んでみました。例を見ると、FaceOSCSyphon.pdeスケッチは Siphon クライアントとして機能します。

あなたの場合、VPT ドキュメント(大きな pdf リンク) の 33 ページによると、処理スケッチはサイフォン サーバーである必要があります。

Processing でExamples > Contributed Libraries > Siphon > Send Frames を実行します。

VPT で、セクションが見つかるまで、右側のレイヤー リストを下に向かってスクロールしますsyph。その後、Send Frames の例で実行された Processing Siphon サーバーを選択できるはずです。

VPT のサイフォン入力

サイフォンでのスケッチの処理

これで、Processing から VPT にフレームを取得する方法が明確になったはずです。

FaceOSC 部分に関しては、SendFrames の例を FaceOSCReceiverClass の例とマージすることをお勧めします。FaceOSC データを読み取りますが、サイフォン クライアントを設定する代わりに、サイフォン サーバーを設定します。

例えば:

//
// a template for receiving face tracking osc messages from
// Kyle McDonald's FaceOSC https://github.com/kylemcdonald/ofxFaceTracker
//
// this example includes a class to abstract the Face data
//
// 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 codeanticode.syphon.*;
import oscP5.*;
OscP5 oscP5;

PGraphics canvas;
SyphonServer server;


// our FaceOSC tracked face dat
Face face = new Face();

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

  oscP5 = new OscP5(this, 8338);

  canvas = createGraphics(640, 480, P2D);

  // Create syhpon server to send frames out.
  server = new SyphonServer(this, "FaceOSC Processing Syphon");
}

void draw() {  
  canvas.beginDraw();
  canvas.background(255);
  canvas.stroke(0);

  if(face.found > 0) {
    canvas.translate(face.posePosition.x, face.posePosition.y);
    canvas.scale(face.poseScale);
    canvas.noFill();
    canvas.ellipse(-20, face.eyeLeft * -9, 20, 7);
    canvas.ellipse(20, face.eyeRight * -9, 20, 7);
    canvas.ellipse(0, 20, face.mouthWidth* 3, face.mouthHeight * 3);
    canvas.ellipse(-5, face.nostrils * -1, 7, 3);
    canvas.ellipse(5, face.nostrils * -1, 7, 3);
    canvas.rectMode(CENTER);
    canvas.fill(0);
    canvas.rect(-20, face.eyebrowLeft * -5, 25, 5);
    canvas.rect(20, face.eyebrowRight * -5, 25, 5);

    print(face.toString());
  }
  canvas.endDraw();
  image(canvas,0,0);
  server.sendImage(canvas);
}

// OSC CALLBACK FUNCTIONS

void oscEvent(OscMessage m) {
  face.parseOSC(m);
}

// a single tracked face from FaceOSC
class Face {

  // num faces found
  int found;

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

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

  Face() {}

  // parse an OSC message from FaceOSC
  // returns true if a message was handled
  boolean parseOSC(OscMessage m) {

    if(m.checkAddrPattern("/found")) {
        found = m.get(0).intValue();
        return true;
    }      

    // pose
    else if(m.checkAddrPattern("/pose/scale")) {
        poseScale = m.get(0).floatValue();
        return true;
    }
    else if(m.checkAddrPattern("/pose/position")) {
        posePosition.x = m.get(0).floatValue();
        posePosition.y = m.get(1).floatValue();
        return true;
    }
    else if(m.checkAddrPattern("/pose/orientation")) {
        poseOrientation.x = m.get(0).floatValue();
        poseOrientation.y = m.get(1).floatValue();
        poseOrientation.z = m.get(2).floatValue();
        return true;
    }

    // gesture
    else if(m.checkAddrPattern("/gesture/mouth/width")) {
        mouthWidth = m.get(0).floatValue();
        return true;
    }
    else if(m.checkAddrPattern("/gesture/mouth/height")) {
        mouthHeight = m.get(0).floatValue();
        return true;
    }
    else if(m.checkAddrPattern("/gesture/eye/left")) {
        eyeLeft = m.get(0).floatValue();
        return true;
    }
    else if(m.checkAddrPattern("/gesture/eye/right")) {
        eyeRight = m.get(0).floatValue();
        return true;
    }
    else if(m.checkAddrPattern("/gesture/eyebrow/left")) {
        eyebrowLeft = m.get(0).floatValue();
        return true;
    }
    else if(m.checkAddrPattern("/gesture/eyebrow/right")) {
        eyebrowRight = m.get(0).floatValue();
        return true;
    }
    else if(m.checkAddrPattern("/gesture/jaw")) {
        jaw = m.get(0).floatValue();
        return true;
    }
    else if(m.checkAddrPattern("/gesture/nostrils")) {
        nostrils = m.get(0).floatValue();
        return true;
    }

    return false;
  }

  // get the current face values as a string (includes end lines)
  String toString() {
    return "found: " + found + "\n"
           + "pose" + "\n"
           + " scale: " + poseScale + "\n"
           + " position: " + posePosition.toString() + "\n"
           + " orientation: " + poseOrientation.toString() + "\n"
           + "gesture" + "\n"
           + " mouth: " + mouthWidth + " " + mouthHeight + "\n"
           + " eye: " + eyeLeft + " " + eyeRight + "\n"
           + " eyebrow: " + eyebrowLeft + " " + eyebrowRight + "\n"
           + " jaw: " + jaw + "\n"
           + " nostrils: " + nostrils + "\n";
  }

};

これはテストされていないマージされたコードであることに注意してください。要点はわかるはずですが、今はテストできません。

VPT を起動する前に、スケッチが実行されていることを確認してください (そうでない場合は、VPT を再起動してください)。

FaceOSCからプロセッシング、サイフォン、VPTへ

于 2015-05-25T10:50:25.713 に答える