I want to load a 3D object(stl file) into the ofxcv face follow example. It’s an iron man mask and ideally I want it to follow the person’s face captured from the webcam. The mask shows up fine when I load it using the ofxAssimpModelLoader addon, but when I add into the face follow example, it does not show up at all. Here is my code:
#include "ofApp.h"
using namespace ofxCv;
using namespace cv;
void ofApp::setup() {
model.loadModel("iron_mask_onepiece.stl");
model.enableTextures();
ofSetVerticalSync(true);
ofSetFrameRate(120);
finder.setup("haarcascade_frontalface_alt2.xml");
finder.setPreset(ObjectFinder::Fast);
finder.getTracker().setSmoothingRate(0.3);
cam.initGrabber(640, 480);
ofEnableAlphaBlending();
}
void ofApp::update() {
cam.update();
if(cam.isFrameNew()) {
finder.update(cam);
}
}
void ofApp::draw() {
cam.draw(0, 0);
for(int i = 0; i < finder.size(); i++) {
ofRectangle object = finder.getObjectSmoothed(i);
ofPushMatrix();
ofTranslate(ofGetWidth(), ofGetHeight() , 0);
//ofSetColor(100, 0, 0, 0);
// model.setScale(.5, .5,.5);
model.setRotation(0, 180, 0, 0 , 0);
model.setRotation(1, 120, 0, 0 , 0);
model.setRotation(2, 180, 0, 0 , 0);
model.setPosition(0, 0 , 0);
model.draw(OF_MESH_POINTS);
ofPopMatrix();
ofPushMatrix();
ofTranslate(object.getPosition());
ofDrawBitmapStringHighlight(ofToString(finder.getLabel(i)), 0, 0);
ofLine(ofVec2f(), toOf(finder.getVelocity(i)) * 10);
ofPopMatrix();
}
}