Пример #1
0
void FaceOsc::sendFaceOsc(ofxFaceTracker& tracker) {
    clearBundle();

    if(tracker.getFound()) {
        addMessage("/found", 1);

        ofVec2f position = tracker.getPosition();
        addMessage("/pose/position", position);
        addMessage("/pose/scale", tracker.getScale());
        ofVec3f orientation = tracker.getOrientation();
        addMessage("/pose/orientation", orientation);

        addMessage("/gesture/mouth/width", tracker.getGesture(ofxFaceTracker::MOUTH_WIDTH));
        addMessage("/gesture/mouth/height", tracker.getGesture(ofxFaceTracker::MOUTH_HEIGHT));
        addMessage("/gesture/eyebrow/left", tracker.getGesture(ofxFaceTracker::LEFT_EYEBROW_HEIGHT));
        addMessage("/gesture/eyebrow/right", tracker.getGesture(ofxFaceTracker::RIGHT_EYEBROW_HEIGHT));
        addMessage("/gesture/eye/left", tracker.getGesture(ofxFaceTracker::LEFT_EYE_OPENNESS));
        addMessage("/gesture/eye/right", tracker.getGesture(ofxFaceTracker::RIGHT_EYE_OPENNESS));
        addMessage("/gesture/jaw", tracker.getGesture(ofxFaceTracker::JAW_OPENNESS));
        addMessage("/gesture/nostrils", tracker.getGesture(ofxFaceTracker::NOSTRIL_FLARE));
    } else {
        addMessage("/found", 0);
    }

    sendBundle();
}
Пример #2
0
void FaceOsc::sendFaceOsc(ofxFaceTracker& tracker) {
    clearBundle();
    
    if(tracker.getFound()) {
        addMessage("/found", 1);
        
        if(bIncludePose) {
            ofVec2f position = tracker.getPosition();
            addMessage("/pose/position", position);
            addMessage("/pose/scale", tracker.getScale());
            ofVec3f orientation = tracker.getOrientation();
            addMessage("/pose/orientation", orientation);
        }
        
        if (bIncludeGestures) {
            addMessage("/gesture/mouth/width", tracker.getGesture(ofxFaceTracker::MOUTH_WIDTH));
            addMessage("/gesture/mouth/height", tracker.getGesture(ofxFaceTracker::MOUTH_HEIGHT));
            addMessage("/gesture/eyebrow/left", tracker.getGesture(ofxFaceTracker::LEFT_EYEBROW_HEIGHT));
            addMessage("/gesture/eyebrow/right", tracker.getGesture(ofxFaceTracker::RIGHT_EYEBROW_HEIGHT));
            addMessage("/gesture/eye/left", tracker.getGesture(ofxFaceTracker::LEFT_EYE_OPENNESS));
            addMessage("/gesture/eye/right", tracker.getGesture(ofxFaceTracker::RIGHT_EYE_OPENNESS));
            addMessage("/gesture/jaw", tracker.getGesture(ofxFaceTracker::JAW_OPENNESS));
            addMessage("/gesture/nostrils", tracker.getGesture(ofxFaceTracker::NOSTRIL_FLARE));
        }
        
        if(bIncludeAllVertices){
            ofVec2f center = tracker.getPosition();
            ofxOscMessage msg;
            msg.setAddress("/raw");
            for(ofVec2f p : tracker.getImagePoints()) {
                if (bNormalizeRaw) {
                    msg.addFloatArg((p.x-center.x)/tracker.getScale());
                    msg.addFloatArg((p.y-center.y)/tracker.getScale());
                }
                else {
                    msg.addFloatArg(p.x);
                    msg.addFloatArg(p.y);
                }
            }
            bundle.addMessage(msg);
        }

    } else {
        addMessage("/found", 0);
    }
    
    sendBundle();
}
Пример #3
0
void ofApp::update() {
	if(faceShift.update()) {
		lastPacket = ofGetElapsedTimef();
		timer.tick();
		clearBundle();
		if(faceShift.getFound()) {
			for(int i = 0; i < addresses.size(); i++) {
				addMessage("/gesture" + addresses[i], faceShift.getBlendshapeWeight(i));
			}
			addMessage("/gesture/eye/gaze/left", faceShift.getLeftEyeRotation());
			addMessage("/gesture/eye/gaze/right", faceShift.getRightEyeRotation());
			addMessage("/pose/position", faceShift.getPosition());
			addMessage("/pose/orientation", faceShift.getRotationEuler());
			addMessage("/timestamp", (float) faceShift.getTimestamp());
			addMessage("/found", 1);
		} else {
			addMessage("/found", 0);
		}
		sendBundle();
	}
}
Пример #4
0
void ofxOscSender::sendParameter( const ofAbstractParameter & parameter){
	if(!parameter.isSerializable()) return;
	if(parameter.type()==typeid(ofParameterGroup).name()){
		string address = "/";
		const vector<string> hierarchy = parameter.getGroupHierarchyNames();
		for(int i=0;i<(int)hierarchy.size()-1;i++){
			address+=hierarchy[i] + "/";
		}
		ofxOscBundle bundle;
		appendParameter(bundle,parameter,address);
		sendBundle(bundle);
	}else{
		string address = "";
		const vector<string> hierarchy = parameter.getGroupHierarchyNames();
		for(int i=0;i<(int)hierarchy.size()-1;i++){
			address+= "/" + hierarchy[i];
		}
		if(address.length()) address += "/";
		ofxOscMessage msg;
		appendParameter(msg,parameter,address);
		sendMessage(msg, false);
	}
}