|
|
@ -7,11 +7,13 @@ void ofApp::setup(){ |
|
|
|
map_fbo.allocate(ofGetWindowWidth() / 2, map_h, GL_RGB); |
|
|
|
map_fbo_alpha.allocate(map_fbo.getWidth(), map_h, GL_RGBA); |
|
|
|
map_fbo_post.allocate(map_fbo.getWidth(), map_h, GL_RGBA); |
|
|
|
|
|
|
|
portrait_fbo.allocate((ofGetWindowWidth() / 2), map_h, GL_RGBA); // this shoould be full with
|
|
|
|
portrait_pre_fbo.allocate((ofGetWindowWidth() / 3) * 1, map_h, GL_RGB); // this should be full, and same below
|
|
|
|
portrait_pre_fbo_alpha.allocate((ofGetWindowWidth() / 3) * 1, map_h, GL_RGBA); |
|
|
|
portrait_cropped.allocate((ofGetWindowWidth() / 3) * 1, map_h, GL_RGB); |
|
|
|
portrait_cropped_alpha.allocate((ofGetWindowWidth() / 3) * 1, map_h, GL_RGBA); |
|
|
|
|
|
|
|
comp_fbo.allocate(ofGetWindowWidth(), map_h, GL_RGBA); |
|
|
|
|
|
|
|
model_outptut_fbo.allocate(map_fbo.getWidth(), map_h, GL_RGB); |
|
|
@ -28,7 +30,6 @@ void ofApp::setup(){ |
|
|
|
model_image_portrait.allocate(portrait_pre_fbo_alpha.getWidth(), portrait_pre_fbo_alpha.getHeight(), OF_IMAGE_COLOR); |
|
|
|
model_image_portrait_cropped.allocate(portrait_pre_fbo_alpha.getWidth(), portrait_pre_fbo_alpha.getHeight(), OF_IMAGE_COLOR); |
|
|
|
|
|
|
|
map_pixels.allocate(map_fbo.getWidth(), map_h, OF_PIXELS_RGB); |
|
|
|
alpha_demo.allocate(portrait_pre_fbo_alpha.getWidth(), portrait_pre_fbo_alpha.getHeight(), OF_IMAGE_COLOR_ALPHA); |
|
|
|
|
|
|
|
/* allocated ofImages in esp_images */ |
|
|
@ -81,8 +82,9 @@ void ofApp::setup(){ |
|
|
|
|
|
|
|
/* camera settings for portrait */ |
|
|
|
CameraPosition cp; |
|
|
|
cp.position = glm::vec3(116.388, -441.054, 967.724); |
|
|
|
cp.rotation = glm::quat(0.9155, 0.3170, 0.02, -0.035); |
|
|
|
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; |
|
|
|
cam_positions.push_back(cp); |
|
|
|
|
|
|
|
cp.position = glm::vec3(7.987, -195.329, 813.56); |
|
|
@ -99,9 +101,9 @@ void ofApp::setup(){ |
|
|
|
portrait_camera.setFarClip(10000); |
|
|
|
portrait_camera.setPosition(cam_positions[0].position); |
|
|
|
portrait_camera.setOrientation(cam_positions[0].rotation); |
|
|
|
portrait_camera.setScale(0.5); |
|
|
|
// portrait_camera.removeAllInteractions();
|
|
|
|
// portrait_camera.disableMouseInput();
|
|
|
|
portrait_camera.setScale(cam_positions[0].scale); |
|
|
|
portrait_camera.removeAllInteractions(); |
|
|
|
portrait_camera.disableMouseInput(); |
|
|
|
|
|
|
|
createNodes("data/json/sv_embeddings.json"); |
|
|
|
|
|
|
@ -134,7 +136,7 @@ void ofApp::update(){ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(current_time - last_updated_time >= 3){ |
|
|
|
if(current_time - last_updated_time >= 1){ |
|
|
|
buildKDTree(); |
|
|
|
getNearestImages(); |
|
|
|
depth_esp.update(); |
|
|
@ -153,6 +155,7 @@ void ofApp::update(){ |
|
|
|
|
|
|
|
/* write pixels to model input image */ |
|
|
|
try{ |
|
|
|
map_pixels.allocate(map_fbo.getWidth(), map_h, OF_PIXELS_RGB); |
|
|
|
map_fbo.readToPixels(map_pixels); |
|
|
|
model_image.setFromPixels(map_pixels); |
|
|
|
} catch (exception e) { |
|
|
@ -172,10 +175,7 @@ void ofApp::update(){ |
|
|
|
} |
|
|
|
|
|
|
|
//mapper.update();
|
|
|
|
bullet.update(server->is_active, server->getChosenNode()); |
|
|
|
|
|
|
|
|
|
|
|
//std::cout << portrait_camera.getPosition() << " : " <<portrait_camera.getOrientationQuat()<< std::endl;
|
|
|
|
bullet.update(server->is_active, server->getChosenNode(), nn_nodes); |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
|
|
@ -223,8 +223,6 @@ void ofApp::draw(){ |
|
|
|
drawPortrait(); |
|
|
|
|
|
|
|
comp_fbo.begin(); |
|
|
|
ofClear(ofColor::lightGrey); //uncommet when changing to map
|
|
|
|
ofBackgroundGradient(ofColor::darkGrey, ofColor::whiteSmoke, OF_GRADIENT_LINEAR); |
|
|
|
shaders.begin(); |
|
|
|
portrait_fbo.draw(ofGetWindowWidth() / 2, 0); |
|
|
|
shaders.setUniformTexture("tex0", t, 0); |
|
|
@ -233,7 +231,6 @@ void ofApp::draw(){ |
|
|
|
shaders.setUniform1f("time", ofGetElapsedTimef()); |
|
|
|
shaders.setUniform1i("frame", ofGetFrameNum()); |
|
|
|
map_fbo_post.draw(0, 0); |
|
|
|
/* actual map */ |
|
|
|
map_fbo_alpha.draw(0,0); |
|
|
|
shaders.end(); |
|
|
|
comp_fbo.end(); |
|
|
@ -245,7 +242,8 @@ void ofApp::draw(){ |
|
|
|
ofTranslate(0, 60); |
|
|
|
comp_fbo.draw(0, 0); |
|
|
|
|
|
|
|
//server->print();
|
|
|
|
if(bullet.print_debug) |
|
|
|
server->print(); |
|
|
|
} |
|
|
|
|
|
|
|
void ofApp::drawPortrait(){ |
|
|
@ -446,6 +444,7 @@ void ofApp::drawPortraitZ(){ |
|
|
|
|
|
|
|
/* creates an fbo with four cropped images, to preprare for model input */ |
|
|
|
void ofApp::getNearestImages(){ |
|
|
|
nn_nodes.clear(); |
|
|
|
glm::vec3 cam_position = bullet.getCameraPosition(); |
|
|
|
queryKD(cam_position, 4); |
|
|
|
|
|
|
@ -456,6 +455,9 @@ void ofApp::getNearestImages(){ |
|
|
|
|
|
|
|
int imageIndex = 0; |
|
|
|
for(auto& img : esp_images){ |
|
|
|
/* add to nn_nodes array */ |
|
|
|
nn_nodes.push_back(&nodes[kd_result[imageIndex].second]); |
|
|
|
|
|
|
|
selected_image = nodes[kd_result[imageIndex].second].img; |
|
|
|
// Calculate the scaling factor
|
|
|
|
float widthRatio = 128.0f / selected_image.getWidth(); |
|
|
@ -649,11 +651,20 @@ void ofApp::keyPressed(int key) { |
|
|
|
ofLog() << "Plane Size: " << plane_size; |
|
|
|
break; |
|
|
|
case 'c': |
|
|
|
cam_pos_idx++; |
|
|
|
if(cam_pos_idx > cam_positions.size() - 1) |
|
|
|
cam_pos_idx = 0; |
|
|
|
portrait_camera.setPosition(cam_positions[cam_pos_idx].position); |
|
|
|
portrait_camera.setOrientation(cam_positions[cam_pos_idx].rotation); |
|
|
|
// cam_pos_idx++;
|
|
|
|
// if(cam_pos_idx > cam_positions.size() - 1)
|
|
|
|
// cam_pos_idx = 0;
|
|
|
|
// 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': |
|
|
|
if(bullet.print_debug){ |
|
|
|
bullet.print_debug = false; |
|
|
|
} else { |
|
|
|
bullet.print_debug = true; |
|
|
|
} |
|
|
|
std::cout << portrait_camera.getPosition() << " : " <<portrait_camera.getOrientationQuat()<< " : " << portrait_camera.getScale() << std::endl; |
|
|
|
break; |
|
|
|
} |
|
|
|
//mapper.keyPressed(key);
|
|
|
|
} |
|
|
|