This commit is contained in:
micuat 2020-10-20 20:12:45 +02:00
parent dab08fed81
commit 788f7b9f9b
4 changed files with 57 additions and 23 deletions

View file

@ -1,6 +1,11 @@
{ {
"files.associations": { "files.associations": {
"*.tidal": "haskell", "*.tidal": "haskell",
"memory_resource": "cpp" "memory_resource": "cpp",
"*.tcc": "cpp",
"fstream": "cpp",
"deque": "cpp",
"string": "cpp",
"vector": "cpp"
} }
} }

View file

@ -111,9 +111,9 @@ vec2 stToV4l2(vec2 v) {
} }
vec2 v4l2ToSt(vec2 v) { vec2 v4l2ToSt(vec2 v) {
v.s += 85; v.s += 115;
v.t += 130; v.t += 170;
v /= 1.5; v /= 1.65;
return v; return v;
} }

View file

@ -8,15 +8,26 @@ void ofApp::setupKinect()
{ {
ofLogNotice(__FUNCTION__) << "Found " << ofxAzureKinect::Device::getInstalledCount() << " installed devices."; ofLogNotice(__FUNCTION__) << "Found " << ofxAzureKinect::Device::getInstalledCount() << " installed devices.";
// Open Kinect.
if (kinectDevice.open())
{
auto kinectSettings = ofxAzureKinect::DeviceSettings(); auto kinectSettings = ofxAzureKinect::DeviceSettings();
kinectSettings.updateIr = false; kinectSettings.updateIr = false;
kinectSettings.updateColor = true; kinectSettings.updateColor = true;
kinectSettings.colorResolution = K4A_COLOR_RESOLUTION_1080P; kinectSettings.colorResolution = K4A_COLOR_RESOLUTION_1080P;
kinectSettings.updateVbo = false; kinectSettings.updateVbo = false;
kinectDevice.startCameras(kinectSettings);
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())
{
kinectDevice.startCameras(kinectSettings, bodyTrackingSettings);
} }
} }
@ -122,7 +133,12 @@ void ofApp::updateThermal()
v4l2Cam.grabFrame(); v4l2Cam.grabFrame();
if (v4l2Cam.isNewFrame()) if (v4l2Cam.isNewFrame())
{ {
auto &body = kinectDevice.getBodyIndexPix();
hotspots.clear(); hotspots.clear();
for (int i = 0; i < kinectDevice.getNumBodies(); i++)
{
hotspots.push_back(std::vector<ofVec3f>());
}
int count = 0; int count = 0;
for (int i = 0; i < camHeight; i++) for (int i = 0; i < camHeight; i++)
{ {
@ -134,7 +150,11 @@ void ofApp::updateThermal()
v4l2Pixels.setColor(count++, a); v4l2Pixels.setColor(count++, a);
if (i % 4 == 0 && j % 4 == 0 && i > 80) 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; return a.z > b.z;
} }
} compareZThermal; } 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("uFrameSize", kinectDevice.getDepthTex().getWidth(), kinectDevice.getDepthTex().getHeight());
shader.setUniform2i("uDepthFrameSize", kinectDevice.getDepthTex().getWidth(), kinectDevice.getDepthTex().getHeight()); shader.setUniform2i("uDepthFrameSize", kinectDevice.getDepthTex().getWidth(), kinectDevice.getDepthTex().getHeight());
shader.setUniform3f("uHottest0", hotspots.at(0)); if (hotspots.size() > 0 && hotspots.at(0).size() > 0)
for(int i = 1; i < hotspots.size(); i++) { {
if(hotspots.at(i).distance(hotspots.at(0)) > 100) { shader.setUniform3f("uHottest0", hotspots.at(0).at(0));
shader.setUniform3f("uHottest1", hotspots.at(i));
break;
} }
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(); cam.end();
} }
drawDebug(); drawDebug();
kinectDevice.getBodyIndexTex().draw(0, 0, 360, 360);
} }
void ofApp::keyPressed(int key) void ofApp::keyPressed(int key)

View file

@ -54,5 +54,5 @@ private:
ofxGpuParticles particles; ofxGpuParticles particles;
std::vector<ofVec3f> hotspots; std::vector<std::vector<ofVec3f>> hotspots;
}; };