From 4591a525c7cfe2054e5b2f5bf773053e6cabf318 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20B=C3=BCrki?= Date: Thu, 25 Jun 2020 15:10:08 +0200 Subject: [PATCH 1/4] Remove option to send whole skeleton --- src/TrackingNetworkManager.cpp | 25 ++++++------------------- src/TrackingNetworkManager.h | 4 ---- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/TrackingNetworkManager.cpp b/src/TrackingNetworkManager.cpp index b6188a6..c6351f3 100644 --- a/src/TrackingNetworkManager.cpp +++ b/src/TrackingNetworkManager.cpp @@ -36,11 +36,6 @@ void TrackingNetworkManager::setup(ofxGui &gui, string _realsenseSerial){ listeningGroup->add(listeningIP.set("RX IP",localAddress)); listeningGroup->add(listeningPort.set("RX Port", NETWORK_LISTENING_PORT, NETWORK_LISTENING_PORT, NETWORK_LISTENING_PORT + 99)); - - streamingGuiGroup.setName("Streaming"); - streamingGuiGroup.add(streamingWholeBody.set("Whole body", true)); - panel->addGroup(streamingGuiGroup); - panel->loadFromFile("broadcast.xml"); // TODO: check usefulness @@ -139,20 +134,12 @@ void TrackingNetworkManager::sendTrackingData(const SkeletonFinder& skeletonFind void TrackingNetworkManager::sendSkeletonData(const Skeleton& skel) { ofxOscMessage skeletonMsg; skeletonMsg.setAddress("/ks/server/track/skeleton"); - if (streamingWholeBody.get()) { - for (auto joint = skel.joints.begin(); joint != skel.joints.end(); ++joint) { - skeletonMsg.addFloatArg(joint->pos.x); - skeletonMsg.addFloatArg(joint->pos.y); - skeletonMsg.addFloatArg(joint->pos.z); - skeletonMsg.addFloatArg(joint->confidence); - } - } else { - 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); - } + + 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); } diff --git a/src/TrackingNetworkManager.h b/src/TrackingNetworkManager.h index bbbdeb6..7b1ab64 100644 --- a/src/TrackingNetworkManager.h +++ b/src/TrackingNetworkManager.h @@ -86,10 +86,6 @@ public: ofParameter listeningPort; ofParameter mServerID; - - ofParameterGroup streamingGuiGroup; - - ofParameter streamingWholeBody; }; -- GitLab From ff327b5f9050eea531a5680ba89f74061a8167b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20B=C3=BCrki?= Date: Thu, 25 Jun 2020 15:36:17 +0200 Subject: [PATCH 2/4] Add ID in messages sent --- src/TrackingNetworkManager.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/TrackingNetworkManager.cpp b/src/TrackingNetworkManager.cpp index c6351f3..c722154 100644 --- a/src/TrackingNetworkManager.cpp +++ b/src/TrackingNetworkManager.cpp @@ -135,6 +135,8 @@ 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); -- GitLab From 0684ac456b9167b405ec1beb55339233319f483e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20B=C3=BCrki?= Date: Thu, 25 Jun 2020 15:40:45 +0200 Subject: [PATCH 3/4] Remove useless fields and methods --- src/TrackingNetworkManager.cpp | 36 +--------------------------------- src/TrackingNetworkManager.h | 7 ------- 2 files changed, 1 insertion(+), 42 deletions(-) diff --git a/src/TrackingNetworkManager.cpp b/src/TrackingNetworkManager.cpp index c722154..8e7e0f5 100644 --- a/src/TrackingNetworkManager.cpp +++ b/src/TrackingNetworkManager.cpp @@ -37,25 +37,13 @@ void TrackingNetworkManager::setup(ofxGui &gui, string _realsenseSerial){ listeningGroup->add(listeningPort.set("RX Port", NETWORK_LISTENING_PORT, NETWORK_LISTENING_PORT, NETWORK_LISTENING_PORT + 99)); panel->loadFromFile("broadcast.xml"); - - // TODO: check usefulness - frameNumber = 0; } //-------------------------------------------------------------- void TrackingNetworkManager::update(const SkeletonFinder& skeletonFinder){ - frameNumber++; - long currentMillis = ofGetElapsedTimeMillis(); - //Check if its about time to send a broadcast message - if(knownClients.size() > 0 && (currentMillis - broadCastTimer) > BROADCAST_CLIENT_FREQ){ - sendBroadCastAddress(); - checkTrackingClients(currentMillis); - } else if(knownClients.size() == 0 && (currentMillis - broadCastTimer) > BROADCAST_NOCLIENT_FREQ){ - sendBroadCastAddress(); - } - + //send trackingdata to all connected clients sendTrackingData(skeletonFinder); @@ -116,14 +104,6 @@ void TrackingNetworkManager::update(const SkeletonFinder& skeletonFinder){ } void TrackingNetworkManager::sendTrackingData(const SkeletonFinder& skeletonFinder) { - // send frame number - ofxOscMessage frame; - frame.setAddress("/ks/server/track/frame/start"); - frame.addIntArg(mServerID.get()); - frame.addIntArg(frameNumber); - sendMessageToTrackingClients(frame); - - vector skeletons = skeletonFinder.getSkeletons(); if (skeletons.size() > 0) { // Only one skeleton is to be on the scene for the perspective to work @@ -179,20 +159,6 @@ int TrackingNetworkManager::getTrackingClientIndex(string _ip, int _port){ return knownClients.size() -1; } -void TrackingNetworkManager::sendBroadCastAddress(){ - ofxOscMessage broadcast; - broadcast.setAddress("/ks/server/broadcast"); - broadcast.addStringArg(mDeviceSerial); - broadcast.addIntArg(mServerID.get()); - broadcast.addStringArg(listeningIP.get()); - broadcast.addIntArg(listeningPort.get()); - - broadcastSender.setup(broadcastIP.get(), broadcastPort.get()); - broadcastSender.sendMessage(broadcast); - - broadCastTimer = ofGetElapsedTimeMillis(); -} - //-------------------------------------------------------------- string TrackingNetworkManager::getOscMsgAsString(ofxOscMessage m){ string msg_string; diff --git a/src/TrackingNetworkManager.h b/src/TrackingNetworkManager.h index 7b1ab64..c7fa3d1 100644 --- a/src/TrackingNetworkManager.h +++ b/src/TrackingNetworkManager.h @@ -13,7 +13,6 @@ #include "ofxOsc.h" #include "TrackingClient.h" #include "SkeletonFinder.h" -#include "Frustum.h" #include #include @@ -41,8 +40,6 @@ public: void sendMessageToTrackingClients(ofxOscMessage _msg); void checkTrackingClients(long _currentMillis); int getTrackingClientIndex(string _ip, int _port); - - void sendBroadCastAddress(); string getOscMsgAsString(ofxOscMessage m); @@ -52,10 +49,6 @@ public: string mDeviceSerial; - float scale; - - long frameNumber; - //---------------------------------------- // Server side: ofxOscReceiver serverReceiver; // OSC receiver -- GitLab From 7abcda1b6815cec5be35ff6bb91d365b2c8ff942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20B=C3=BCrki?= Date: Thu, 25 Jun 2020 15:44:11 +0200 Subject: [PATCH 4/4] Add alert when multiple skeletons are detected --- src/TrackingNetworkManager.cpp | 11 ++++++++++- src/TrackingNetworkManager.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/TrackingNetworkManager.cpp b/src/TrackingNetworkManager.cpp index 8e7e0f5..b1b9229 100644 --- a/src/TrackingNetworkManager.cpp +++ b/src/TrackingNetworkManager.cpp @@ -43,7 +43,7 @@ void TrackingNetworkManager::setup(ofxGui &gui, string _realsenseSerial){ //-------------------------------------------------------------- void TrackingNetworkManager::update(const SkeletonFinder& skeletonFinder){ long currentMillis = ofGetElapsedTimeMillis(); - + //send trackingdata to all connected clients sendTrackingData(skeletonFinder); @@ -107,10 +107,19 @@ void TrackingNetworkManager::sendTrackingData(const SkeletonFinder& skeletonFind vector skeletons = skeletonFinder.getSkeletons(); if (skeletons.size() > 0) { // Only one skeleton is to be on the scene for the perspective to work + if (skeletons.size() > 1) { + sendMultipleSkeletonsAlert(); + } sendSkeletonData(skeletons[0]); } } +void TrackingNetworkManager::sendMultipleSkeletonsAlert() { + ofxOscMessage alertMsg; + alertMsg.setAddress("/ks/server/track/multiple-skeletons"); + sendMessageToTrackingClients(alertMsg); +} + void TrackingNetworkManager::sendSkeletonData(const Skeleton& skel) { ofxOscMessage skeletonMsg; skeletonMsg.setAddress("/ks/server/track/skeleton"); diff --git a/src/TrackingNetworkManager.h b/src/TrackingNetworkManager.h index c7fa3d1..bf5d09c 100644 --- a/src/TrackingNetworkManager.h +++ b/src/TrackingNetworkManager.h @@ -36,6 +36,7 @@ public: void sendTrackingData(const SkeletonFinder& skeletonFinder); void sendSkeletonData(const Skeleton& skeleton); + void sendMultipleSkeletonsAlert(); void sendMessageToTrackingClients(ofxOscMessage _msg); void checkTrackingClients(long _currentMillis); -- GitLab