body wip
This commit is contained in:
parent
dab08fed81
commit
788f7b9f9b
4 changed files with 57 additions and 23 deletions
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
|
@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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.
|
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())
|
if (kinectDevice.open())
|
||||||
{
|
{
|
||||||
auto kinectSettings = ofxAzureKinect::DeviceSettings();
|
kinectDevice.startCameras(kinectSettings, bodyTrackingSettings);
|
||||||
kinectSettings.updateIr = false;
|
|
||||||
kinectSettings.updateColor = true;
|
|
||||||
kinectSettings.colorResolution = K4A_COLOR_RESOLUTION_1080P;
|
|
||||||
kinectSettings.updateVbo = false;
|
|
||||||
kinectDevice.startCameras(kinectSettings);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,10 +102,10 @@ void ofApp::setup()
|
||||||
for (unsigned x = 0; x < w; ++x)
|
for (unsigned x = 0; x < w; ++x)
|
||||||
{
|
{
|
||||||
unsigned idx = y * w + x;
|
unsigned idx = y * w + x;
|
||||||
particlePosns[idx * 4] = 0; //
|
particlePosns[idx * 4] = 0; //
|
||||||
particlePosns[idx * 4 + 1] = ofRandomf(); // age
|
particlePosns[idx * 4 + 1] = ofRandomf(); // age
|
||||||
particlePosns[idx * 4 + 2] = 0.f; //
|
particlePosns[idx * 4 + 2] = 0.f; //
|
||||||
particlePosns[idx * 4 + 3] = 0.f; //
|
particlePosns[idx * 4 + 3] = 0.f; //
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
particles.loadDataTexture(ofxGpuParticles::MISC, particlePosns);
|
particles.loadDataTexture(ofxGpuParticles::MISC, particlePosns);
|
||||||
|
@ -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)
|
||||||
|
|
|
@ -54,5 +54,5 @@ private:
|
||||||
|
|
||||||
ofxGpuParticles particles;
|
ofxGpuParticles particles;
|
||||||
|
|
||||||
std::vector<ofVec3f> hotspots;
|
std::vector<std::vector<ofVec3f>> hotspots;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue