Browse Source

blue&white depth-map added

tsns-map
cailean 3 months ago
parent
commit
a84c188f0e
  1. 46
      src/ofApp.cpp
  2. 2
      src/ofApp.h

46
src/ofApp.cpp

@ -23,9 +23,9 @@ void ofApp::setup(){
depth.Setup(modelPath, false, true); depth.Setup(modelPath, false, true);
emotion.Setup(modelPath3, false, true); emotion.Setup(modelPath3, false, true);
/* Load shader, allocated rampedFbo */
depthToColourShader.load("data/shader/rampShader.vert", "data/shader/rampShader.frag"); depthToColourShader.load("data/shader/rampShader.vert", "data/shader/rampShader.frag");
rampedFbo.allocate(1600, 800, GL_RGB); rampedFbo.allocate(1600, 800);
drawMesh =ofMesh::plane(1600, 800 );
} }
@ -47,11 +47,10 @@ void ofApp::update(){
map.Draw(); map.Draw();
} }
/* Setup model input using ofImage */ /* Setup model input using ofImage, allocated fbo */
player.Update(img); player.Update(img);
img.setFromPixels(player.GetVideoPixels()); img.setFromPixels(player.GetVideoPixels());
/* Run Models */ /* Run Models */
try{ try{
auto output_tensors = depth.Run(map.fboImage); auto output_tensors = depth.Run(map.fboImage);
@ -114,26 +113,7 @@ void ofApp::update(){
//-------------------------------------------------------------- //--------------------------------------------------------------
void ofApp::draw(){ void ofApp::draw(){
map.Draw(); map.Draw();
//fbo.draw(0, 0); renderDepthMap();
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);
if(!firstRun){ if(!firstRun){
faceDetector.DrawBox(detected_faces); 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){ void ofApp::keyPressed(int key){
if (key=OF_KEY_LEFT){ if (key=OF_KEY_LEFT){

2
src/ofApp.h

@ -28,6 +28,7 @@ class ofApp : public ofBaseApp{
void dragEvent(ofDragInfo dragInfo); void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg); void gotMessage(ofMessage msg);
void inferEmotionalState(); void inferEmotionalState();
void renderDepthMap();
ofImage img; ofImage img;
ofFbo fbo; ofFbo fbo;
@ -52,5 +53,4 @@ class ofApp : public ofBaseApp{
ofShader depthToColourShader; ofShader depthToColourShader;
ofFbo rampedFbo; ofFbo rampedFbo;
ofMesh drawMesh;
}; };

Loading…
Cancel
Save