|
|
@ -23,9 +23,9 @@ void ofApp::setup(){ |
|
|
|
depth.Setup(modelPath, false, true); |
|
|
|
emotion.Setup(modelPath3, false, true); |
|
|
|
|
|
|
|
/* Load shader, allocated rampedFbo */ |
|
|
|
depthToColourShader.load("data/shader/rampShader.vert", "data/shader/rampShader.frag"); |
|
|
|
rampedFbo.allocate(1600, 800, GL_RGB); |
|
|
|
drawMesh =ofMesh::plane(1600, 800 ); |
|
|
|
rampedFbo.allocate(1600, 800); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -47,11 +47,10 @@ void ofApp::update(){ |
|
|
|
map.Draw(); |
|
|
|
} |
|
|
|
|
|
|
|
/* Setup model input using ofImage */ |
|
|
|
/* Setup model input using ofImage, allocated fbo */ |
|
|
|
player.Update(img); |
|
|
|
img.setFromPixels(player.GetVideoPixels()); |
|
|
|
|
|
|
|
|
|
|
|
/* Run Models */ |
|
|
|
try{ |
|
|
|
auto output_tensors = depth.Run(map.fboImage); |
|
|
@ -114,26 +113,7 @@ void ofApp::update(){ |
|
|
|
//--------------------------------------------------------------
|
|
|
|
void ofApp::draw(){ |
|
|
|
map.Draw(); |
|
|
|
//fbo.draw(0, 0);
|
|
|
|
|
|
|
|
auto& texCoords = drawMesh.getTexCoords(); |
|
|
|
auto& tex = rampedFbo.getTexture(); |
|
|
|
for( auto& tc : texCoords ){ |
|
|
|
tc = rampedFbo.getTexture().getCoordFromPercent(tc.x, (1.0-tc.y)); |
|
|
|
} |
|
|
|
|
|
|
|
rampedFbo.begin(); |
|
|
|
depthToColourShader.begin(); |
|
|
|
depthToColourShader.setUniformTexture("alphaTex", fbo.getTexture(), 0); |
|
|
|
ofPushMatrix(); |
|
|
|
// translate to center of window because ofMesh::plane origin is in the center //
|
|
|
|
ofTranslate(ofGetWidth()/2, ofGetHeight()/2 ); |
|
|
|
drawMesh.draw(); |
|
|
|
ofPopMatrix(); |
|
|
|
depthToColourShader.end(); |
|
|
|
rampedFbo.end(); |
|
|
|
|
|
|
|
rampedFbo.draw(0, 0); |
|
|
|
renderDepthMap(); |
|
|
|
|
|
|
|
if(!firstRun){ |
|
|
|
faceDetector.DrawBox(detected_faces); |
|
|
@ -187,6 +167,22 @@ void ofApp::inferEmotionalState(){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void ofApp::renderDepthMap(){ |
|
|
|
rampedFbo.begin(); |
|
|
|
|
|
|
|
depthToColourShader.begin(); |
|
|
|
depthToColourShader.setUniformTexture("tex0", fbo.getTexture(), 0); |
|
|
|
depthToColourShader.setUniformTexture("tex1", map.fboImage.getTexture(), 1); |
|
|
|
depthToColourShader.setUniform1f("texW", rampedFbo.getWidth()); |
|
|
|
depthToColourShader.setUniform1f("texH", rampedFbo.getHeight()); |
|
|
|
fbo.draw(0, 0); |
|
|
|
depthToColourShader.end(); |
|
|
|
|
|
|
|
rampedFbo.end(); |
|
|
|
|
|
|
|
rampedFbo.draw(0,0); |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
void ofApp::keyPressed(int key){ |
|
|
|
if (key=OF_KEY_LEFT){ |
|
|
|