diff --git a/src/ofApp.cpp b/src/ofApp.cpp index b37e69fd9f8b073e14e98554d2b6c30e55ece6ed..b5bf67186ec53e493c237ec4d919a255c6060a72 100644 --- a/src/ofApp.cpp +++ b/src/ofApp.cpp @@ -179,6 +179,8 @@ void ofApp::setup(){ capMesh.reSize(4); ofLog(OF_LOG_NOTICE) << "Setup over"; + + lastSettingsWriteTime = boost::filesystem::last_write_time(networkSettingsPath); } //-------------------------------------------------------------- @@ -247,6 +249,8 @@ void ofApp::update(){ ofBackground(100, 100, 100); + checkSettingsUpdate(); + #ifdef BLOB if(realSense->update(ofxRealSenseTwo::PointCloud::VIDEO)) { @@ -271,6 +275,43 @@ void ofApp::update(){ networkMng.update(tracker); } +void ofApp::saveSettings() +{ + tracker.panel->saveToFile("trackings.xml"); + networkMng.panel->saveToFile("broadcast.xml"); + guitransform->saveToFile("transformation.xml"); + +#ifdef BLOB + tracker.saveMask(); + post->saveToFile("postprocessing.xml"); + device->saveToFile(realSense->getSerialNumber(-1) + ".xml"); +#endif +} + +void ofApp::loadSettings() +{ + tracker.panel->loadFromFile("trackings.xml"); + networkMng.panel->loadFromFile("broadcast.xml"); + guitransform->loadFromFile("transformation.xml"); + reloadTransformMatrix(); +#ifdef BLOB + tracker.loadMask(); + post->loadFromFile("postprocessing.xml"); + // This seems to make the app crash on Linux + //device->loadFromFile(realSense->getSerialNumber(-1) + ".xml"); +#endif +} + +void ofApp::checkSettingsUpdate() { + std::time_t newLastWriteTime = boost::filesystem::last_write_time(networkSettingsPath); + + if (newLastWriteTime > lastSettingsWriteTime) { + lastSettingsWriteTime = newLastWriteTime; + + loadSettings(); + } +} + void ofApp::draw() { ofSetColor(255, 255, 255); @@ -444,27 +485,11 @@ void ofApp::keyPressed(int key){ break; case 's': - tracker.panel->saveToFile("trackings.xml"); - networkMng.panel->saveToFile("broadcast.xml"); - guitransform->saveToFile("transformation.xml"); -#ifdef BLOB - tracker.saveMask(); - post->saveToFile("postprocessing.xml"); - device->saveToFile(realSense->getSerialNumber(-1) + ".xml"); -#endif + saveSettings(); break; case 'l': - tracker.panel->loadFromFile("trackings.xml"); - networkMng.panel->loadFromFile("broadcast.xml"); - guitransform->loadFromFile("transformation.xml"); - reloadTransformMatrix(); -#ifdef BLOB - tracker.loadMask(); - post->loadFromFile("postprocessing.xml"); - // This seems to make the app crash on Linux - //device->loadFromFile(realSense->getSerialNumber(-1) + ".xml"); -#endif + loadSettings(); break; case 'h': diff --git a/src/ofApp.h b/src/ofApp.h index b269f56447e8d6a53e44e07926a940f99b333b2a..11315b19cb5668c536828d7b4a619d6676884696 100644 --- a/src/ofApp.h +++ b/src/ofApp.h @@ -11,6 +11,7 @@ #include "Frustum.h" #include "CaptureMeshArray.h" #include "PointCloudManager.h" +#include #include "DetectionMethod.h" #ifdef BLOB @@ -23,7 +24,7 @@ #include "SkeletonFinder.h" #endif -#include +#include #define N_CAMERAS 3 @@ -165,7 +166,14 @@ public: ofParameter pixelSizeCorrector; ofParameter blobGrain; ofParameter captureVideo; - + + void saveSettings(); + void loadSettings(); + + void checkSettingsUpdate(); + const boost::filesystem::path networkSettingsPath = ofFilePath::getAbsolutePath("broadcast.xml"); + std::time_t lastSettingsWriteTime; + ////////// // HELP // //////////