Browse Source

tex coords wont work!

tsns-map
cailean 3 months ago
parent
commit
d859084ee3
  1. 1
      src/Map.cpp
  2. 5
      src/Onnx.cpp
  3. 2
      src/Onnx.h
  4. 1
      src/main.cpp
  5. 28
      src/ofApp.cpp
  6. 2
      src/ofApp.h

1
src/Map.cpp

@ -6,7 +6,6 @@ Map::Map(){
}
void Map::Setup(){
ofDisableArbTex();
scale = 10000;
isDebug = true;

5
src/Onnx.cpp

@ -228,7 +228,7 @@ void Onnx::Normalize(float* data, size_t size, float min_value, float max_value)
}
// Coverts the output tensor data to a texture of a given ofFbo.
void Onnx::DataToFbo(const float* data, size_t width, size_t height, ofFbo& fbo, ofShader& shader){
void Onnx::DataToFbo(const float* data, size_t width, size_t height, ofFbo& fbo){
// Convert data into opencv mat
cv::Mat inputMat(height, width, CV_32FC1, const_cast<float*>(data));
@ -254,11 +254,8 @@ void Onnx::DataToFbo(const float* data, size_t width, size_t height, ofFbo& fbo,
// Update FBO with new pixels
fbo.begin();
shader.begin();
ofTexture& texture = fbo.getTexture();
texture.loadData(pixels);
shader.setUniformTexture("tex", texture, 0);
shader.end();
fbo.end();

2
src/Onnx.h

@ -31,7 +31,7 @@
float ReduceMin(const float* data, size_t size);
float ReduceMax(const float* data, size_t size);
void Normalize(float* data, size_t size, float min_value, float max_value);
void DataToFbo(const float* data, size_t width, size_t height, ofFbo& fbo, ofShader& shader);
void DataToFbo(const float* data, size_t width, size_t height, ofFbo& fbo);
void Softmax(float* data, size_t size);
bool timeStamp = false;
bool log = false;

1
src/main.cpp

@ -7,6 +7,7 @@ int main( ){
//Use ofGLFWWindowSettings for more options like multi-monitor fullscreen
ofGLWindowSettings settings;
settings.setSize(1600, 800);
settings.setGLVersion(3, 2);
settings.windowMode = OF_WINDOW; //can also be OF_FULLSCREEN
auto window = ofCreateWindow(settings);

28
src/ofApp.cpp

@ -2,6 +2,7 @@
//--------------------------------------------------------------
void ofApp::setup(){
ofDisableArbTex();
ofSetFrameRate(24);
ofSetVerticalSync(true);
@ -23,6 +24,8 @@ void ofApp::setup(){
emotion.Setup(modelPath3, false, true);
depthToColourShader.load("data/shader/rampShader.vert", "data/shader/rampShader.frag");
rampedFbo.allocate(1600, 800, GL_RGB);
drawMesh =ofMesh::plane(1600, 800 );
}
@ -60,7 +63,7 @@ void ofApp::update(){
depth.Normalize(output_ptr, num_elements, min_value, max_value);
depth.DataToFbo(output_ptr, 518, 518, fbo, depthToColourShader);
depth.DataToFbo(output_ptr, 518, 518, fbo);
auto output_tensors_face = yolo.Run(map.fboImage);
@ -110,10 +113,27 @@ void ofApp::update(){
//--------------------------------------------------------------
void ofApp::draw(){
map.Draw();
fbo.draw(0, 0);
//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);
if(!firstRun){
faceDetector.DrawBox(detected_faces);

2
src/ofApp.h

@ -51,4 +51,6 @@ class ofApp : public ofBaseApp{
Map map;
ofShader depthToColourShader;
ofFbo rampedFbo;
ofMesh drawMesh;
};

Loading…
Cancel
Save