diff --git a/zoneb/bin/data/settings.xml b/zoneb/bin/data/settings.xml index ec814d2..7c9c085 100644 --- a/zoneb/bin/data/settings.xml +++ b/zoneb/bin/data/settings.xml @@ -3,4 +3,5 @@ 61.2245, -12.2449 1.869 video3 + 7 diff --git a/zoneb/src/ofApp.cpp b/zoneb/src/ofApp.cpp index 68d49ad..3b28c3f 100644 --- a/zoneb/src/ofApp.cpp +++ b/zoneb/src/ofApp.cpp @@ -50,9 +50,11 @@ void ofApp::setupThermal() v4l2Cam.settings(ofxV4L2_AUTOGAIN, set_autogain); v4l2Cam.settings(ofxV4L2_GAIN, set_gain); - // we use a texture because the ofxV4L2 class has no draw method (yet) - // we use GL_LUMINANCE because the ofxV4L2 class supports only grayscale (for now) - v4l2Tex.allocate(512, 512, GL_RGB); + v4l2Buffer.resize(60); + for (int i = 0; i < v4l2Buffer.size(); i++) + { + v4l2Buffer.at(i).allocate(512, 512, GL_RGB); + } v4l2Pixels.allocate(512, 512, OF_PIXELS_RGB); for (int i = 0; i < 512; i++) @@ -125,13 +127,14 @@ 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(v4l2Delay.setup("thermo delay", 0, 0, 59)); gui.add(captureDeviceName.setup("device", "video3")); gui.loadFromFile("settings.xml"); gui.setPosition(10, 10); debugGui.setup("DEBUG"); debugGui.add(calibMode.setup("calib", false)); - debugGui.add(dummyMode.setup("dummy", true)); // should be false + debugGui.add(dummyMode.setup("dummy", true)); // should be false debugGui.add(dummyXY.setup("XY", {0, 0}, {-500, -1000}, {500, 500})); // should be false debugGui.add(debugFps.setup("FPS", "0")); debugGui.setPosition(230, 10); @@ -211,7 +214,9 @@ void ofApp::updateThermal() } } } - v4l2Tex.allocate(v4l2Pixels); + v4l2Buffer.at(v4l2BufferCount).allocate(v4l2Pixels); + v4l2BufferCount = (v4l2BufferCount + 1) % (v4l2Delay + 1); + struct { bool operator()(ofVec3f a, ofVec3f b) const @@ -305,7 +310,7 @@ void ofApp::drawMain() auto tex = kinectDevice.getDepthTex(); boundShader.setUniformTexture("u_depth", tex); boundShader.setUniformTexture("u_ofcam", fbos.at("ofcam")); - boundShader.setUniformTexture("u_v4l2cam", v4l2Tex); + boundShader.setUniformTexture("u_v4l2cam", v4l2Buffer.at(v4l2BufferCount)); boundShader.setUniform1i("u_calib", calibMode == true ? 1 : 0); boundShader.setUniform2f("u_calibXY", registrationXY); boundShader.setUniform1f("u_calibScale", registrationScale); @@ -328,7 +333,7 @@ void ofApp::draw() { particles.whateverImages.at("u_depth") = kinectDevice.getDepthTex(); particles.whateverImages.at("u_world") = kinectDevice.getDepthToWorldTex(); - particles.whateverImages.at("u_v4l2cam") = v4l2Tex; + particles.whateverImages.at("u_v4l2cam") = v4l2Buffer.at(v4l2BufferCount); fbos.at("ofcam").begin(); ofClear(0); diff --git a/zoneb/src/ofApp.h b/zoneb/src/ofApp.h index 2fa5991..aee6b49 100644 --- a/zoneb/src/ofApp.h +++ b/zoneb/src/ofApp.h @@ -55,6 +55,8 @@ private: ofxV4L2 v4l2Cam; ofTexture v4l2Tex; + std::vector v4l2Buffer; + int v4l2BufferCount; ofPixels v4l2Pixels; ofxGpuParticles particles; @@ -66,6 +68,7 @@ private: ofxVec2Slider registrationXY; ofxFloatSlider registrationScale; + ofxIntSlider v4l2Delay; ofxInputField captureDeviceName; ofxPanel gui;