From da807473af6ab48ce125fef8fd20fa03252186e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20B=C3=BCrki?= Date: Wed, 19 Aug 2020 10:44:18 +0200 Subject: [PATCH 1/5] Add default constructor for BlobTracker --- src/BlobTracker.cpp | 3 +++ src/BlobTracker.h | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/BlobTracker.cpp b/src/BlobTracker.cpp index 049ffde..fab1fde 100644 --- a/src/BlobTracker.cpp +++ b/src/BlobTracker.cpp @@ -19,6 +19,9 @@ BlobTracker::BlobTracker(int _ID, int _liveSpan, ofRectangle _rect, glm::vec3 _h update(_rect, _headBlobCenter, _headBlobSize, _headTop, 0); } +BlobTracker::BlobTracker() : + BlobTracker(0, 0, ofRectangle(), glm::vec3(), glm::vec2(), glm::vec3()) {} + void BlobTracker::updatePrepare() { mHasBeenUpdated = false; diff --git a/src/BlobTracker.h b/src/BlobTracker.h index ef15ca3..cb96287 100644 --- a/src/BlobTracker.h +++ b/src/BlobTracker.h @@ -22,7 +22,8 @@ class BlobTracker { public: BlobTracker(int _ID, int _liveSpan, ofRectangle _rect, glm::vec3 _headBlobCenter, glm::vec2 _headBlobSize, glm::vec3 _headTop); - + BlobTracker(); + // returns true if the event is alive bool isActive(); -- GitLab From 7101339f050713433416bb7bb43754fc6f61eb81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20B=C3=BCrki?= Date: Wed, 19 Aug 2020 10:44:37 +0200 Subject: [PATCH 2/5] Send dummy messages when no body is found --- src/TrackingNetworkManager.cpp | 61 +++++++++++++++++++++------------- src/TrackingNetworkManager.h | 2 ++ 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/src/TrackingNetworkManager.cpp b/src/TrackingNetworkManager.cpp index 8e42e7c..9f8b2ee 100644 --- a/src/TrackingNetworkManager.cpp +++ b/src/TrackingNetworkManager.cpp @@ -90,7 +90,7 @@ void TrackingNetworkManager::update(const BodyFinder& bodyFinder){ } //this is purely workaround for a mysterious OSCpack bug on 64bit linux - // after startup, reinit the receivers + // after startup, reinit the receivers@ // must be a timing problem, though - in debug, stepping through, it works. if(ofGetFrameNum() == 60){ serverReceiver.setup(NETWORK_LISTENING_PORT); @@ -99,6 +99,8 @@ void TrackingNetworkManager::update(const BodyFinder& bodyFinder){ void TrackingNetworkManager::sendTrackingData(const BodyFinder& bodyFinder) { +// TODO: send nothing as well + #ifdef BLOB vector blobs = bodyFinder.blobEvents; vector activeBlobs; @@ -113,6 +115,8 @@ void TrackingNetworkManager::sendTrackingData(const BodyFinder& bodyFinder) { return; } sendBlobData(activeBlobs[0]); + } else { + sendNoBodyFound(); } #else vector skeletons = bodyFinder.getSkeletons(); @@ -125,6 +129,8 @@ void TrackingNetworkManager::sendTrackingData(const BodyFinder& bodyFinder) { return; } sendSkeletonData(skeletons[0]); + } else { + sendNoBodyFound(); } #endif } @@ -132,13 +138,39 @@ void TrackingNetworkManager::sendTrackingData(const BodyFinder& bodyFinder) { /** * Send a special message via OSC to signal multiple bodies */ -void TrackingNetworkManager::sendMultipleBodiesAlert() -{ +void TrackingNetworkManager::sendMultipleBodiesAlert() { ofxOscMessage alertMsg; alertMsg.setAddress("/ks/server/track/multiple-bodies"); sendMessageToTrackingClients(alertMsg); } +void TrackingNetworkManager::sendNoBodyFound() { + +#ifdef BLOB + string address = "/ks/server/track/headblob"; +#else + string address = "/ks/server/track/skeleton"; +#endif + + sendBody(address, glm::vec3(), -1.0f); +} + +void TrackingNetworkManager::sendBody(string address, glm::vec3 position, float confidence) { + ofxOscMessage message; + message.setAddress(address); + + message.addIntArg(mServerID.get()); + + message.addFloatArg(position.x); + message.addFloatArg(position.y); + message.addFloatArg(position.z); + + message.addFloatArg(confidence); + + sendMessageToTrackingClients(message); + +} + #ifdef BLOB /** * Send a given blob via OSC @@ -146,16 +178,7 @@ void TrackingNetworkManager::sendMultipleBodiesAlert() */ void TrackingNetworkManager::sendBlobData(const BlobTracker& blob) { - ofxOscMessage blobMsg; - blobMsg.setAddress("/ks/server/track/headblob"); - - blobMsg.addIntArg(mServerID.get()); - - blobMsg.addFloatArg(blob.headBlobCenter.x); - blobMsg.addFloatArg(blob.headBlobCenter.y); - blobMsg.addFloatArg(blob.headBlobCenter.z); - - sendMessageToTrackingClients(blobMsg); + sendBody("/ks/server/track/headblob", blob.headBlobCenter, 1.0f); } #else /** @@ -163,18 +186,8 @@ void TrackingNetworkManager::sendBlobData(const BlobTracker& blob) */ void TrackingNetworkManager::sendSkeletonData(const Skeleton& skel) { - ofxOscMessage skeletonMsg; - skeletonMsg.setAddress("/ks/server/track/skeleton"); - - skeletonMsg.addIntArg(mServerID.get()); - Joint head = skel.joints[nuitrack::JOINT_HEAD]; - skeletonMsg.addFloatArg(head.pos.x); - skeletonMsg.addFloatArg(head.pos.y); - skeletonMsg.addFloatArg(head.pos.z); - skeletonMsg.addFloatArg(head.confidence); - - sendMessageToTrackingClients(skeletonMsg); + sendBody("/ks/server/track/skeleton", head.pos, head.confidence); } #endif diff --git a/src/TrackingNetworkManager.h b/src/TrackingNetworkManager.h index 59ae2ce..eb1bdb2 100644 --- a/src/TrackingNetworkManager.h +++ b/src/TrackingNetworkManager.h @@ -48,6 +48,8 @@ public: void update(const BodyFinder& bodyFinder); void sendTrackingData(const BodyFinder& bodyFinder); void sendMultipleBodiesAlert(); + void sendNoBodyFound(); + void sendBody(string address, glm::vec3 position, float confidence); #ifdef BLOB void sendBlobData(const BlobTracker& blob); -- GitLab From 05afe60e767e57e5782ba323aaeb9c93c19e04ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20B=C3=BCrki?= Date: Wed, 19 Aug 2020 10:45:10 +0200 Subject: [PATCH 3/5] Fix includes for non-blob version --- src/ofApp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ofApp.h b/src/ofApp.h index 335a3a7..df4803b 100644 --- a/src/ofApp.h +++ b/src/ofApp.h @@ -9,7 +9,6 @@ #include "TrackingNetworkManager.h" #include "Frustum.h" #include "CaptureMeshArray.h" -#include "PointCloudManager.h" #include #include "DetectionMethod.h" @@ -21,6 +20,7 @@ #include "ofxNuitrack.h" #include #include "SkeletonFinder.h" + #include "PointCloudManager.h" #endif #include -- GitLab From 5509b8a240e6150eba3bed917147044cde9c65a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20B=C3=BCrki?= Date: Wed, 19 Aug 2020 10:45:52 +0200 Subject: [PATCH 4/5] Fix mask generation --- src/ofApp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ofApp.cpp b/src/ofApp.cpp index 87dedd4..f31d40a 100644 --- a/src/ofApp.cpp +++ b/src/ofApp.cpp @@ -416,7 +416,7 @@ void ofApp::drawCapturePointCloud(bool _mask) { if (_mask) { shader.setUniform1i("mask", 1); - glPointSize(6 * 4); + glPointSize(2); } else { shader.setUniform1i("mask", 0); -- GitLab From 49ba261bf3ea4151ff31532ede21e33bb77170ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20B=C3=BCrki?= Date: Wed, 19 Aug 2020 10:49:50 +0200 Subject: [PATCH 5/5] Add new debug visuals --- src/ofApp.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/ofApp.cpp b/src/ofApp.cpp index f31d40a..afe7bb2 100644 --- a/src/ofApp.cpp +++ b/src/ofApp.cpp @@ -278,7 +278,7 @@ void ofApp::update() ofBackground(100, 100, 100); #ifdef BLOB - if(realSense->update(ofxRealSenseTwo::PointCloud::VIDEO)) + if(realSense->update(ofxRealSenseTwo::PointCloud::DEPTH)) { if (maskUpdatesCounter < MASK_UPDATE_CYCLES) { @@ -348,10 +348,21 @@ void ofApp::draw() { if(bShowVisuals){ +#ifdef BLOB + if (bDisplayBlobTrackerVision) { + tracker.filteredImage.draw(viewMain); + } else { + previewCam.begin(viewMain); + mainGrid.drawPlane(5., 5, false); + drawPreview(); + previewCam.end(); + } +#else previewCam.begin(viewMain); mainGrid.drawPlane(5., 5, false); drawPreview(); previewCam.end(); +#endif glDisable(GL_DEPTH_TEST); ofPushStyle(); @@ -450,11 +461,12 @@ void ofApp::exit() { void ofApp::createHelp(){ stringstream helpStream; helpStream << "press v -> to show visualizations\n"; - helpStream << "press 1 - 3 -> to change the viewport\n"; - helpStream << "press p -> to show pointcloud\n"; +#ifdef BLOB + helpStream << "press p -> to show filtered capture space\n"; +#endif helpStream << "\n"; helpStream << "press h -> to show help \n"; - helpStream << "press l -> to load last saved settings\n"; + helpStream << "press l -> to load settings\n"; help = helpStream.str(); } @@ -466,7 +478,7 @@ void ofApp::keyPressed(int key){ break; case 'p': - bPreviewPointCloud = !bPreviewPointCloud; + bDisplayBlobTrackerVision = !bDisplayBlobTrackerVision; break; case 'v': -- GitLab