|
|
@ -2,7 +2,7 @@ |
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
void ofApp::setup(){ |
|
|
|
|
|
|
|
draw_face = true; |
|
|
|
/* allocated fbo's */ |
|
|
|
map_fbo.allocate(ofGetWindowWidth() / 2, map_h, GL_RGB); |
|
|
|
map_fbo_alpha.allocate(map_fbo.getWidth(), map_h, GL_RGBA); |
|
|
@ -32,6 +32,14 @@ void ofApp::setup(){ |
|
|
|
|
|
|
|
alpha_demo.allocate(portrait_pre_fbo_alpha.getWidth(), portrait_pre_fbo_alpha.getHeight(), OF_IMAGE_COLOR_ALPHA); |
|
|
|
|
|
|
|
/* black pi mapper bg */ |
|
|
|
mapper_black.allocate(300, 1080, GL_RGB); |
|
|
|
mapper_black.begin(); |
|
|
|
ofClear(0, 0, 0, 255); |
|
|
|
mapper_black.end(); |
|
|
|
|
|
|
|
mapper_black.getTexture().setTextureMinMagFilter(GL_NEAREST, GL_NEAREST); |
|
|
|
|
|
|
|
/* allocated ofImages in esp_images */ |
|
|
|
for(int i = 0; i < 4; i++){ |
|
|
|
ofFbo temp; |
|
|
@ -44,7 +52,6 @@ void ofApp::setup(){ |
|
|
|
ofSetVerticalSync(true); |
|
|
|
ofDisableArbTex(); |
|
|
|
ofEnableDepthTest(); |
|
|
|
ofDisableAntiAliasing(); |
|
|
|
ofEnableAlphaBlending(); |
|
|
|
|
|
|
|
/* load */ |
|
|
@ -64,9 +71,10 @@ void ofApp::setup(){ |
|
|
|
bullet.setup(); |
|
|
|
|
|
|
|
/* pi mapper setup */ |
|
|
|
// mapper.registerFboSource(projection_src);
|
|
|
|
// mapper.setup();
|
|
|
|
// projection_src.setFbo(&comp_fbo);
|
|
|
|
mapper.registerFboSource(projection_src); |
|
|
|
mapper.setup(); |
|
|
|
projection_src.setFbo(&comp_fbo); |
|
|
|
projection_src.setFbo(&mapper_black); |
|
|
|
|
|
|
|
/* onnx setup */ |
|
|
|
depth_onnx.Setup(modelPath, false, true); |
|
|
@ -85,25 +93,35 @@ void ofApp::setup(){ |
|
|
|
cp.position = glm::vec3(-131.228, 502.624, 706.1); |
|
|
|
cp.rotation = glm::quat(0.898726, -0.436474, -0.0351978, -0.0170607); |
|
|
|
cp.scale = 0.313542; |
|
|
|
cp.mode = CameraMode::ORTHO; |
|
|
|
cp.depth_mult = 400; |
|
|
|
cam_positions.push_back(cp); |
|
|
|
|
|
|
|
cp.position = glm::vec3(7.987, -195.329, 813.56); |
|
|
|
cp.rotation = glm::quat(0.993, 0.117, 0.005, -0.00057); |
|
|
|
cp.position = glm::vec3(-55.0256, -561.005, 750.691); |
|
|
|
cp.rotation = glm::quat(0.938642, 0.340495, 0.0493511, -0.0177967); |
|
|
|
cp.scale = 0.313542; |
|
|
|
cp.mode = CameraMode::PERSP; |
|
|
|
cp.depth_mult = 600; |
|
|
|
cam_positions.push_back(cp); |
|
|
|
|
|
|
|
cp.position = glm::vec3(160.81, -87.86, 731.575); |
|
|
|
cp.rotation = glm::quat(0.980, 0.027, 0.1934, -0.0053); |
|
|
|
cam_positions.push_back(cp); |
|
|
|
cp.position = glm::vec3(-13.9031, -573.818, 730.531); |
|
|
|
cp.rotation = glm::quat(0.902208, 0.429743, 0.029696, -0.0140357); |
|
|
|
cp.scale = 0.313542; |
|
|
|
cp.mode =CameraMode::PERSP; |
|
|
|
cp.depth_mult = 600; |
|
|
|
//cam_positions.push_back(cp);
|
|
|
|
|
|
|
|
/* settings */ |
|
|
|
portrait_camera.enableOrtho(); |
|
|
|
portrait_camera.setNearClip(-10000); |
|
|
|
portrait_camera.setFarClip(10000); |
|
|
|
portrait_camera.setPosition(cam_positions[0].position); |
|
|
|
portrait_camera.setOrientation(cam_positions[0].rotation); |
|
|
|
portrait_camera.setScale(cam_positions[0].scale); |
|
|
|
portrait_camera.removeAllInteractions(); |
|
|
|
portrait_camera.disableMouseInput(); |
|
|
|
current_cp = cam_positions[1]; |
|
|
|
portrait_camera.setPosition(current_cp.position); |
|
|
|
portrait_camera.setOrientation(current_cp.rotation); |
|
|
|
portrait_camera.setScale(current_cp.scale); |
|
|
|
updateCurrentCameraMode(); |
|
|
|
// portrait_camera.removeAllInteractions();
|
|
|
|
// portrait_camera.disableMouseInput();
|
|
|
|
|
|
|
|
createNodes("data/json/sv_embeddings.json"); |
|
|
|
|
|
|
@ -132,6 +150,7 @@ void ofApp::update(){ |
|
|
|
if(n.tsne_position != last_chosen_node.tsne_position) { |
|
|
|
portrait_needs_update = true; |
|
|
|
last_chosen_node = n; |
|
|
|
//current_cp = cam_positions[ofRandom(cam_positions.size())];
|
|
|
|
} else { |
|
|
|
portrait_needs_update = false; |
|
|
|
} |
|
|
@ -178,7 +197,7 @@ void ofApp::update(){ |
|
|
|
std::cout << "Model did not run" << std::endl; |
|
|
|
} |
|
|
|
|
|
|
|
//mapper.update();
|
|
|
|
mapper.update(); |
|
|
|
bullet.update(server->is_active, server->getChosenNode(), nn_nodes); |
|
|
|
|
|
|
|
if(tsne_update_complete) { |
|
|
@ -190,6 +209,8 @@ void ofApp::update(){ |
|
|
|
tsne_iter_idx = (tsne_iter_idx + 1) % 3; |
|
|
|
updateTSNEPositions(nodes); |
|
|
|
} |
|
|
|
|
|
|
|
//updateCurrentCameraMode();
|
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
|
|
@ -246,15 +267,15 @@ void ofApp::draw(){ |
|
|
|
shaders.setUniform1i("frame", ofGetFrameNum()); |
|
|
|
map_fbo_post.draw(0, 0); |
|
|
|
map_fbo_alpha.draw(0,0); |
|
|
|
//alpha_demo.draw(0, 0);
|
|
|
|
shaders.end(); |
|
|
|
comp_fbo.end(); |
|
|
|
|
|
|
|
comp_fbo.getTexture().setTextureMinMagFilter(GL_NEAREST, GL_NEAREST); |
|
|
|
|
|
|
|
//mapper.draw();
|
|
|
|
|
|
|
|
ofTranslate(0, 60); |
|
|
|
ofTranslate(0, 0); |
|
|
|
comp_fbo.draw(0, 0); |
|
|
|
mapper.draw(); |
|
|
|
|
|
|
|
if(bullet.print_debug) |
|
|
|
server->print(); |
|
|
@ -316,7 +337,7 @@ void ofApp::drawPortrait(){ |
|
|
|
|
|
|
|
if(yolo.checkInferenceComplete()) { |
|
|
|
/* check if face is detected, and crop potrait */ |
|
|
|
if(detected_faces.size() > 0){ |
|
|
|
if(detected_faces.size() > 0 && draw_face){ |
|
|
|
for(auto& f : detected_faces){ |
|
|
|
float crop_width = f.box.x2 - f.box.x1; |
|
|
|
float crop_height = f.box.y2 - f.box.y1; |
|
|
@ -405,7 +426,7 @@ void ofApp::drawPortraitZ(){ |
|
|
|
/* if no faces found use full portrait texture */ |
|
|
|
ofTexture tex_color; |
|
|
|
|
|
|
|
if(detected_faces.size() > 0){ |
|
|
|
if(detected_faces.size() > 0 && draw_face){ |
|
|
|
tex_color = portrait_cropped_alpha.getTexture(); |
|
|
|
} else { |
|
|
|
tex_color = portrait_pre_fbo_alpha.getTexture(); |
|
|
@ -438,44 +459,45 @@ void ofApp::drawPortraitZ(){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Second plane with offset
|
|
|
|
ofPushMatrix(); |
|
|
|
p_depth.begin(); |
|
|
|
p_depth.setUniform1f("gridSize", g_size); |
|
|
|
p_depth.setUniform2f("resolution", glm::vec2(portrait_fbo.getWidth(), portrait_fbo.getHeight())); |
|
|
|
p_depth.setUniform2f("threshold", glm::vec2(minDepth, max_r)); |
|
|
|
p_depth.setUniformTexture("tex0", tex_color, 0); |
|
|
|
p_depth.setUniformTexture("tex1", tex_depth, 1); |
|
|
|
ofFill(); |
|
|
|
// Offset the second plane - adjust these values as needed
|
|
|
|
ofTranslate(p_noise_x - 50, p_noise_y - 0, -150); // moved right (+200), up (+100) and back (-300)
|
|
|
|
ofRotateDeg(60, 0, 1, 0); |
|
|
|
plane.draw(); |
|
|
|
p_depth.end(); |
|
|
|
ofPopMatrix(); |
|
|
|
ofDisableDepthTest(); |
|
|
|
|
|
|
|
// Second plane with offset
|
|
|
|
ofPushMatrix(); |
|
|
|
p_depth.begin(); |
|
|
|
p_depth.setUniform1f("gridSize", g_size); |
|
|
|
p_depth.setUniform2f("resolution", glm::vec2(portrait_fbo.getWidth(), portrait_fbo.getHeight())); |
|
|
|
p_depth.setUniform2f("threshold", glm::vec2(minDepth, max_r)); |
|
|
|
p_depth.setUniformTexture("tex0", tex_color, 0); |
|
|
|
p_depth.setUniformTexture("tex1", tex_depth, 1); |
|
|
|
ofFill(); |
|
|
|
// Offset the second plane - adjust these values as needed
|
|
|
|
ofTranslate(p_noise_x - 140, p_noise_y - 0, -150); // moved right (+200), up (+100) and back (-300)
|
|
|
|
ofRotateDeg(-60, 0, 1, 0); |
|
|
|
plane.draw(); |
|
|
|
p_depth.end(); |
|
|
|
ofPopMatrix(); |
|
|
|
ofDisableDepthTest(); |
|
|
|
// // Second plane with offset
|
|
|
|
// ofPushMatrix();
|
|
|
|
// p_depth.begin();
|
|
|
|
// p_depth.setUniform1f("gridSize", g_size);
|
|
|
|
// p_depth.setUniform2f("resolution", glm::vec2(portrait_fbo.getWidth(), portrait_fbo.getHeight()));
|
|
|
|
// p_depth.setUniform2f("threshold", glm::vec2(minDepth, max_r));
|
|
|
|
// p_depth.setUniformTexture("tex0", tex_color, 0);
|
|
|
|
// p_depth.setUniformTexture("tex1", tex_depth, 1);
|
|
|
|
// ofFill();
|
|
|
|
// // Offset the second plane - adjust these values as needed
|
|
|
|
// ofTranslate(p_noise_x - 50, p_noise_y - 0, -150); // moved right (+200), up (+100) and back (-300)
|
|
|
|
// ofRotateDeg(60, 0, 1, 0);
|
|
|
|
// plane.draw();
|
|
|
|
// p_depth.end();
|
|
|
|
// ofPopMatrix();
|
|
|
|
// ofDisableDepthTest();
|
|
|
|
|
|
|
|
// // Second plane with offset
|
|
|
|
// ofPushMatrix();
|
|
|
|
// p_depth.begin();
|
|
|
|
// p_depth.setUniform1f("gridSize", g_size);
|
|
|
|
// p_depth.setUniform2f("resolution", glm::vec2(portrait_fbo.getWidth(), portrait_fbo.getHeight()));
|
|
|
|
// p_depth.setUniform2f("threshold", glm::vec2(minDepth, max_r));
|
|
|
|
// p_depth.setUniformTexture("tex0", tex_color, 0);
|
|
|
|
// p_depth.setUniformTexture("tex1", tex_depth, 1);
|
|
|
|
// ofFill();
|
|
|
|
// // Offset the second plane - adjust these values as needed
|
|
|
|
// ofTranslate(p_noise_x - 140, p_noise_y - 0, -150); // moved right (+200), up (+100) and back (-300)
|
|
|
|
// ofRotateDeg(-60, 0, 1, 0);
|
|
|
|
// plane.draw();
|
|
|
|
// p_depth.end();
|
|
|
|
// ofPopMatrix();
|
|
|
|
// ofDisableDepthTest();
|
|
|
|
|
|
|
|
|
|
|
|
ofPushMatrix(); |
|
|
|
p_depth.begin(); |
|
|
|
p_depth.setUniform1f("gridSize", g_size); |
|
|
|
p_depth.setUniform1f("depth_mult", current_cp.depth_mult); |
|
|
|
p_depth.setUniform2f("resolution", glm::vec2(portrait_fbo.getWidth(), portrait_fbo.getHeight())); |
|
|
|
p_depth.setUniform2f("threshold", glm::vec2(minDepth, max_r)); |
|
|
|
p_depth.setUniformTexture("tex0", tex_color, 0); |
|
|
@ -485,6 +507,7 @@ void ofApp::drawPortraitZ(){ |
|
|
|
plane.draw(); |
|
|
|
p_depth.end(); |
|
|
|
ofPopMatrix(); |
|
|
|
ofDisableDepthTest(); |
|
|
|
|
|
|
|
portrait_camera.end(); |
|
|
|
} |
|
|
@ -562,6 +585,7 @@ void ofApp::createNodes(std::string json_path){ |
|
|
|
if(addNode) { // Only process when flag is true
|
|
|
|
Node n; |
|
|
|
n.img.load(j["image"]); |
|
|
|
n.img_path = (j["image"]); |
|
|
|
n.tex = n.img.getTexture(); |
|
|
|
n.error = j["error"]; |
|
|
|
std::vector<float> t_embedding; |
|
|
@ -741,7 +765,7 @@ void ofApp::keyPressed(int key) { |
|
|
|
portrait_camera.setPosition(cam_positions[cam_pos_idx].position); |
|
|
|
portrait_camera.setOrientation(cam_positions[cam_pos_idx].rotation); |
|
|
|
portrait_camera.setScale(cam_positions[cam_pos_idx].scale); |
|
|
|
case 'p': |
|
|
|
case 'n': |
|
|
|
if(bullet.print_debug){ |
|
|
|
bullet.print_debug = false; |
|
|
|
} else { |
|
|
@ -752,8 +776,18 @@ void ofApp::keyPressed(int key) { |
|
|
|
case 't': |
|
|
|
tsne_iter_idx++; |
|
|
|
updateTSNEPositions(nodes); |
|
|
|
case 'v': |
|
|
|
ofToggleFullscreen(); |
|
|
|
case 'o': |
|
|
|
if(draw_face){ |
|
|
|
draw_face = false; |
|
|
|
} else { |
|
|
|
draw_face = true; |
|
|
|
} |
|
|
|
case 'e': |
|
|
|
current_cp = cam_positions[ofRandom(cam_positions.size())]; |
|
|
|
} |
|
|
|
//mapper.keyPressed(key);
|
|
|
|
mapper.keyPressed(key); |
|
|
|
} |
|
|
|
|
|
|
|
// Your main thread function:
|
|
|
@ -766,22 +800,43 @@ void ofApp::onTSNEUpdateComplete() { |
|
|
|
} |
|
|
|
|
|
|
|
void ofApp::keyReleased(int key){ |
|
|
|
//mapper.keyReleased(key);
|
|
|
|
mapper.keyReleased(key); |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
void ofApp::mouseDragged(int x, int y, int button){ |
|
|
|
//mapper.mouseDragged(x, y, button);
|
|
|
|
mapper.mouseDragged(x, y, button); |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
void ofApp::mousePressed(int x, int y, int button){ |
|
|
|
//mapper.mousePressed(x, y, button);
|
|
|
|
mapper.mousePressed(x, y, button); |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
|
|
|
void ofApp::mouseReleased(int x, int y, int button){ |
|
|
|
//mapper.mouseReleased(x, y, button);
|
|
|
|
mapper.mouseReleased(x, y, button); |
|
|
|
} |
|
|
|
|
|
|
|
void ofApp::updateCurrentCameraMode(){ |
|
|
|
if(current_cp.mode == CameraMode::ORTHO){ |
|
|
|
portrait_camera.enableOrtho(); |
|
|
|
portrait_camera.setNearClip(-10000); |
|
|
|
portrait_camera.setFarClip(10000); |
|
|
|
draw_face = true; |
|
|
|
plane_size = 70; |
|
|
|
} else { |
|
|
|
portrait_camera.disableOrtho(); |
|
|
|
portrait_camera.setNearClip(0); |
|
|
|
portrait_camera.setFarClip(0); |
|
|
|
draw_face = false; |
|
|
|
plane_size = 55; |
|
|
|
} |
|
|
|
portrait_camera.setPosition(current_cp.position); |
|
|
|
portrait_camera.setOrientation(current_cp.rotation); |
|
|
|
portrait_camera.setScale(current_cp.scale); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ofMesh ofApp::createCustomPlane(float width, float height, int numX, int numY) { |
|
|
|