diff --git a/.vscode/settings.json b/.vscode/settings.json index 9fce203..a8c27d7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,11 @@ { "files.associations": { "*.tidal": "haskell", - "memory_resource": "cpp" + "memory_resource": "cpp", + "*.tcc": "cpp", + "fstream": "cpp", + "deque": "cpp", + "string": "cpp", + "vector": "cpp" } } \ No newline at end of file diff --git a/zoneb/bin/data/shaders/particles/update.frag b/zoneb/bin/data/shaders/particles/update.frag index d8aa649..5ecc5c3 100755 --- a/zoneb/bin/data/shaders/particles/update.frag +++ b/zoneb/bin/data/shaders/particles/update.frag @@ -111,9 +111,9 @@ vec2 stToV4l2(vec2 v) { } vec2 v4l2ToSt(vec2 v) { - v.s += 85; - v.t += 130; - v /= 1.5; + v.s += 115; + v.t += 170; + v /= 1.65; return v; } diff --git a/zoneb/src/ofApp.cpp b/zoneb/src/ofApp.cpp index fa368e4..ad5dcfd 100644 --- a/zoneb/src/ofApp.cpp +++ b/zoneb/src/ofApp.cpp @@ -8,15 +8,26 @@ void ofApp::setupKinect() { ofLogNotice(__FUNCTION__) << "Found " << ofxAzureKinect::Device::getInstalledCount() << " installed devices."; - // Open Kinect. + auto kinectSettings = ofxAzureKinect::DeviceSettings(); + kinectSettings.updateIr = false; + kinectSettings.updateColor = true; + kinectSettings.colorResolution = K4A_COLOR_RESOLUTION_1080P; + kinectSettings.updateVbo = false; + + auto deviceSettings = ofxAzureKinect::DeviceSettings(); + deviceSettings.syncImages = false; + deviceSettings.depthMode = K4A_DEPTH_MODE_NFOV_UNBINNED; + deviceSettings.updateIr = false; + deviceSettings.updateColor = false; + //deviceSettings.colorResolution = K4A_COLOR_RESOLUTION_1080P; + deviceSettings.updateWorld = true; + deviceSettings.updateVbo = false; + auto bodyTrackingSettings = ofxAzureKinect::BodyTrackingSettings(); + //bodyTrackingSettings.processingMode = K4ABT_TRACKER_PROCESSING_MODE_CPU; + bodyTrackingSettings.updateBodies = true; if (kinectDevice.open()) { - auto kinectSettings = ofxAzureKinect::DeviceSettings(); - kinectSettings.updateIr = false; - kinectSettings.updateColor = true; - kinectSettings.colorResolution = K4A_COLOR_RESOLUTION_1080P; - kinectSettings.updateVbo = false; - kinectDevice.startCameras(kinectSettings); + kinectDevice.startCameras(kinectSettings, bodyTrackingSettings); } } @@ -91,10 +102,10 @@ void ofApp::setup() for (unsigned x = 0; x < w; ++x) { unsigned idx = y * w + x; - particlePosns[idx * 4] = 0; // + particlePosns[idx * 4] = 0; // particlePosns[idx * 4 + 1] = ofRandomf(); // age - particlePosns[idx * 4 + 2] = 0.f; // - particlePosns[idx * 4 + 3] = 0.f; // + particlePosns[idx * 4 + 2] = 0.f; // + particlePosns[idx * 4 + 3] = 0.f; // } } particles.loadDataTexture(ofxGpuParticles::MISC, particlePosns); @@ -122,7 +133,12 @@ void ofApp::updateThermal() v4l2Cam.grabFrame(); if (v4l2Cam.isNewFrame()) { + auto &body = kinectDevice.getBodyIndexPix(); hotspots.clear(); + for (int i = 0; i < kinectDevice.getNumBodies(); i++) + { + hotspots.push_back(std::vector()); + } int count = 0; for (int i = 0; i < camHeight; i++) { @@ -134,7 +150,11 @@ void ofApp::updateThermal() v4l2Pixels.setColor(count++, a); if (i % 4 == 0 && j % 4 == 0 && i > 80) { - hotspots.push_back(ofVec3f(j, i, a)); + auto c = body.getColor(j, i); + if (c.r < hotspots.size()) + { + hotspots.at(c.r).push_back(ofVec3f(j, i, a)); + } } } } @@ -146,7 +166,10 @@ void ofApp::updateThermal() return a.z > b.z; } } compareZThermal; - std::sort(hotspots.begin(), hotspots.end(), compareZThermal); + for (int i = 0; i < hotspots.size(); i++) + { + std::sort(hotspots.at(i).begin(), hotspots.at(i).end(), compareZThermal); + } } } @@ -167,12 +190,17 @@ void ofApp::onParticlesUpdate(ofxShader &shader) shader.setUniform2i("uFrameSize", kinectDevice.getDepthTex().getWidth(), kinectDevice.getDepthTex().getHeight()); shader.setUniform2i("uDepthFrameSize", kinectDevice.getDepthTex().getWidth(), kinectDevice.getDepthTex().getHeight()); - shader.setUniform3f("uHottest0", hotspots.at(0)); - for(int i = 1; i < hotspots.size(); i++) { - if(hotspots.at(i).distance(hotspots.at(0)) > 100) { - shader.setUniform3f("uHottest1", hotspots.at(i)); - break; - } + if (hotspots.size() > 0 && hotspots.at(0).size() > 0) + { + shader.setUniform3f("uHottest0", hotspots.at(0).at(0)); + } + if (hotspots.size() > 1 && hotspots.at(1).size() > 0) + { + shader.setUniform3f("uHottest1", hotspots.at(1).at(0)); + } + else if (hotspots.size() > 0 && hotspots.at(0).size() > 0) { + shader.setUniform3f("uHottest1", hotspots.at(0).at(1)); + } } @@ -216,6 +244,7 @@ void ofApp::draw() cam.end(); } drawDebug(); + kinectDevice.getBodyIndexTex().draw(0, 0, 360, 360); } void ofApp::keyPressed(int key) diff --git a/zoneb/src/ofApp.h b/zoneb/src/ofApp.h index f4e4d37..de4670c 100644 --- a/zoneb/src/ofApp.h +++ b/zoneb/src/ofApp.h @@ -54,5 +54,5 @@ private: ofxGpuParticles particles; - std::vector hotspots; + std::vector> hotspots; };