From 1e3498fbdb2ceb18cb6bb79e7de0519e2833f22d Mon Sep 17 00:00:00 2001 From: micuat Date: Mon, 26 Oct 2020 10:46:08 +0100 Subject: [PATCH] gui to file / set dev file --- zoneb/addons.make | 1 + zoneb/bin/data/settings.xml | 6 ++++ zoneb/src/ofApp.cpp | 55 ++++++++++++++++++++++++------------- zoneb/src/ofApp.h | 9 ++++++ 4 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 zoneb/bin/data/settings.xml diff --git a/zoneb/addons.make b/zoneb/addons.make index 87ad7a9..e634f29 100644 --- a/zoneb/addons.make +++ b/zoneb/addons.make @@ -1,4 +1,5 @@ ofxAzureKinect ofxGpuParticles +ofxGui ofxV4L2 ofxShader diff --git a/zoneb/bin/data/settings.xml b/zoneb/bin/data/settings.xml new file mode 100644 index 0000000..4e77d2a --- /dev/null +++ b/zoneb/bin/data/settings.xml @@ -0,0 +1,6 @@ + + + -208, -257 + 2 + video3 + diff --git a/zoneb/src/ofApp.cpp b/zoneb/src/ofApp.cpp index d3092d2..6def3fc 100644 --- a/zoneb/src/ofApp.cpp +++ b/zoneb/src/ofApp.cpp @@ -39,7 +39,8 @@ void ofApp::setupThermal() v4l2Cam.setDesiredFramerate(60); // use this to set appropriate device and capture method - v4l2Cam.initGrabber("/dev/video2", IO_METHOD_MMAP, camWidth, camHeight); + std::string dev = captureDeviceName; + v4l2Cam.initGrabber((std::string("/dev/") + dev).c_str(), IO_METHOD_MMAP, camWidth, camHeight); // some initial settings int set_gain = 2.0; @@ -63,23 +64,8 @@ void ofApp::setupThermal() } } -void ofApp::setup() +void ofApp::setupParticles() { - // ofDisableArbTex(); - // ofSetVerticalSync(false); - //ofSetLogLevel(OF_LOG_VERBOSE); - - setupKinect(); - setupThermal(); - - boundShader.allocate(ofGetWidth(), ofGetHeight()); - boundShader.load("shaders/bound.frag"); - - fbos.insert({"ofcam", ofFbo()}); - fbos.at("ofcam").allocate(ofGetWidth(), ofGetHeight(), GL_RGBA32F_ARB); - - gradient.load("gradient.jpg"); - // 1,000,000 particles unsigned w = 512; unsigned h = 512; @@ -130,6 +116,36 @@ void ofApp::setup() ofAddListener(particles.drawEvent, this, &ofApp::onParticlesDraw); } +void ofApp::setupGui() +{ + gui.setup("ZONE B", "settings.xml"); // most of the time you don't need a name + gui.add(registrationXY.setup("XY", {-208, -257}, {-400, -400}, {400, 400})); + gui.add(registrationScale.setup("scale", 2.0, 0.1, 3)); + gui.add(captureDeviceName.setup("device", "video3")); + gui.loadFromFile("settings.xml"); +} + +void ofApp::setup() +{ + // ofDisableArbTex(); + // ofSetVerticalSync(false); + //ofSetLogLevel(OF_LOG_VERBOSE); + + setupGui(); + setupKinect(); + setupThermal(); + + boundShader.allocate(ofGetWidth(), ofGetHeight()); + boundShader.load("shaders/bound.frag"); + + fbos.insert({"ofcam", ofFbo()}); + fbos.at("ofcam").allocate(ofGetWidth(), ofGetHeight(), GL_RGBA32F_ARB); + + gradient.load("gradient.jpg"); + + setupParticles(); +} + void ofApp::exit() { kinectDevice.close(); @@ -150,8 +166,8 @@ void ofApp::updateThermal() { for (int j = 0; j < 512; j++) { - int x = j * 1.65 - 115; - int y = i * 1.65 - 170; + int x = j * registrationScale + registrationXY->x; + int y = i * registrationScale + registrationXY->y; if (ofInRange(x, 0, camWidth - 1) == false || ofInRange(y, 0, camHeight - 1) == false) { continue; @@ -251,6 +267,7 @@ void ofApp::drawMain() void ofApp::drawDebug() { + gui.draw(); ofDrawBitmapStringHighlight(ofToString(ofGetFrameRate(), 2) + " FPS", 10, 20); } diff --git a/zoneb/src/ofApp.h b/zoneb/src/ofApp.h index de4670c..6deda36 100644 --- a/zoneb/src/ofApp.h +++ b/zoneb/src/ofApp.h @@ -2,6 +2,8 @@ #include "ofMain.h" +#include "ofxGui.h" + #include "ofxAzureKinect.h" #include "ofxShaderFilter.h" @@ -16,6 +18,8 @@ class ofApp public: void setupKinect(); void setupThermal(); + void setupParticles(); + void setupGui(); void setup(); void exit(); @@ -55,4 +59,9 @@ private: ofxGpuParticles particles; std::vector> hotspots; + + ofxVec2Slider registrationXY; + ofxFloatSlider registrationScale; + ofxInputField captureDeviceName; + ofxPanel gui; };