我正在使用带有 FaceOSCSyphon 的处理,并且需要使用虹吸管将帧从处理发送到 VPT。我需要在我的代码中添加什么才能使其正常工作?
问问题
868 次
1 回答
0
我没有使用过 FaceOSCSyphon,但玩了一下 FaceTracker 库。查看示例,FaceOSCSyphon.pde草图充当虹吸客户端。
在您的情况下,根据VPT 文档(大 pdf 链接)的第 33 页,您的处理草图需要是虹吸服务器。
在处理中运行示例 > 贡献库 > 虹吸 > 发送帧。
在 VPT 中,将右侧的层列表向下滚动,直到找到该syph
部分。然后,您应该能够选择发送帧示例运行的处理虹吸服务器:
现在您应该清楚地了解如何将帧从处理中获取到 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)
于 2015-05-25T10:50:25.713 回答