|
|
@ -61,8 +61,7 @@ void ofApp::setup(){ |
|
|
|
ORTCHAR_T* modelPath_Yolo = "/home/cailean/Desktop/openframeworks/of_v0.12.0_linux64gcc6_release/apps/myApps/image-to-mesh/bin/data/models/yolov5s-face.onnx"; |
|
|
|
ORTCHAR_T* modelPath_Indoor_Dynamic = "/home/cailean/Desktop/openframeworks/of_v0.12.0_linux64gcc6_release/apps/myApps/image-to-mesh/bin/data/models/depth_anything_v2_vitl.onnx"; |
|
|
|
|
|
|
|
/* bullet setup */ |
|
|
|
bullet.setup(nodes); |
|
|
|
bullet.setup(); |
|
|
|
|
|
|
|
/* pi mapper setup */ |
|
|
|
// mapper.registerFboSource(projection_src);
|
|
|
@ -118,6 +117,7 @@ void ofApp::setup(){ |
|
|
|
server->start(); |
|
|
|
|
|
|
|
last_updated_time = ofGetElapsedTimef(); |
|
|
|
last_updated_time_esp = ofGetElapsedTimef(); |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
|
|
@ -137,14 +137,17 @@ void ofApp::update(){ |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(current_time - last_updated_time >= 1){ |
|
|
|
if(current_time - last_updated_time >= 0.1){ |
|
|
|
buildKDTree(); |
|
|
|
getNearestImages(); |
|
|
|
depth_esp.update(); |
|
|
|
depth_onnx_esp.SetPixels(model_esp_out_fbo); |
|
|
|
last_updated_time = current_time; |
|
|
|
} |
|
|
|
|
|
|
|
if(current_time - last_updated_time_esp >= 4.0){ |
|
|
|
depth_esp.update(); |
|
|
|
depth_onnx_esp.SetPixels(model_esp_out_fbo); |
|
|
|
last_updated_time_esp = current_time; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(ofGetFrameNum() < 1){ |
|
|
@ -177,6 +180,16 @@ void ofApp::update(){ |
|
|
|
|
|
|
|
//mapper.update();
|
|
|
|
bullet.update(server->is_active, server->getChosenNode(), nn_nodes); |
|
|
|
|
|
|
|
if(tsne_update_complete) { |
|
|
|
tsne_update_complete = false; // Reset flag
|
|
|
|
onTSNEUpdateComplete(); // Call your main thread function
|
|
|
|
} |
|
|
|
|
|
|
|
if(ofGetElapsedTimef() > tsne_start_time + TNSE_DURATION){ |
|
|
|
tsne_iter_idx = (tsne_iter_idx + 1) % 9; |
|
|
|
updateTSNEPositions(nodes); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//--------------------------------------------------------------
|
|
|
@ -386,8 +399,6 @@ void ofApp::drawPortrait(){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ofApp::drawPortraitZ(){ |
|
|
|
ofBackgroundGradient(ofColor::white, ofColor::orange, OF_GRADIENT_LINEAR); |
|
|
|
|
|
|
@ -586,13 +597,50 @@ void ofApp::createNodes(std::string json_path){ |
|
|
|
|
|
|
|
tsne_points = tsne.run(tsne_input, dims, perplexity, theta, normalise, runManually); |
|
|
|
|
|
|
|
// Option 1: Using nested loops
|
|
|
|
for(size_t i = 0; i < 9; i++) { |
|
|
|
for(size_t t = 0; t <= 100; t++) { |
|
|
|
tsne_points = tsne.iterate(); |
|
|
|
} |
|
|
|
point_iterations.push_back(tsne_points); |
|
|
|
} |
|
|
|
|
|
|
|
for(size_t i = 0; i < tsne_points.size(); i++){ |
|
|
|
const auto& vec = tsne_points[i]; |
|
|
|
const auto& vec = point_iterations[0][i]; |
|
|
|
auto& n = nodes[i]; |
|
|
|
n.tsne_position = (glm::vec3(((vec[0] * 2) - 1) * tsne_scale, ((vec[1] * 2) - 1) * tsne_scale, -5.0f)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void ofApp::updateTSNEPositions(vector<Node>& _nodes){ |
|
|
|
if(tsne_updating) { |
|
|
|
ofLog() << "TSNE update already in progress"; |
|
|
|
return; |
|
|
|
} |
|
|
|
tsne_updating = true; |
|
|
|
tsne_update_complete = false; // Reset flag
|
|
|
|
tsne_thread = std::thread(&ofApp::updateTSNEPositionsThreaded, this, std::ref(_nodes)); |
|
|
|
tsne_thread.detach(); |
|
|
|
} |
|
|
|
|
|
|
|
void ofApp::updateTSNEPositionsThreaded(vector<Node>& _nodes){ |
|
|
|
ofLog() << "Starting TSNE update in thread"; |
|
|
|
{ |
|
|
|
std::lock_guard<std::mutex> lock(nodes_mutex); |
|
|
|
for(size_t i = 0; i < point_iterations[tsne_iter_idx].size(); i++) { |
|
|
|
const auto& vec = point_iterations[tsne_iter_idx][i]; |
|
|
|
nodes[i].tsne_position = glm::vec3( |
|
|
|
((vec[0] * 2) - 1) * tsne_scale, |
|
|
|
((vec[1] * 2) - 1) * tsne_scale, |
|
|
|
-5.0f |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
tsne_updating = false; |
|
|
|
tsne_update_complete = true; // Set completion flag
|
|
|
|
ofLog() << "TSNE update complete"; |
|
|
|
} |
|
|
|
|
|
|
|
std::vector<std::vector<double>> ofApp::createDoubleVectorFromNodes(const std::vector<Node>& nodes) { |
|
|
|
std::vector<std::vector<double>> result; |
|
|
|
result.reserve(nodes.size()); |
|
|
@ -701,10 +749,22 @@ void ofApp::keyPressed(int key) { |
|
|
|
} |
|
|
|
std::cout << portrait_camera.getPosition() << " : " <<portrait_camera.getOrientationQuat()<< " : " << portrait_camera.getScale() << std::endl; |
|
|
|
break; |
|
|
|
case 't': |
|
|
|
tsne_iter_idx++; |
|
|
|
updateTSNEPositions(nodes); |
|
|
|
} |
|
|
|
//mapper.keyPressed(key);
|
|
|
|
} |
|
|
|
|
|
|
|
// Your main thread function:
|
|
|
|
void ofApp::onTSNEUpdateComplete() { |
|
|
|
// Do whatever you need to do after TSNE update
|
|
|
|
// This will run on the main thread
|
|
|
|
bullet.updateTSNEPosition(nodes); |
|
|
|
tsne_start_time = ofGetElapsedTimef(); |
|
|
|
ofLog() << "Handling TSNE update completion on main thread"; |
|
|
|
} |
|
|
|
|
|
|
|
void ofApp::keyReleased(int key){ |
|
|
|
//mapper.keyReleased(key);
|
|
|
|
} |
|
|
|