diff --git a/src/TrackingNetworkManager.cpp b/src/TrackingNetworkManager.cpp index b6188a628ed64d571c3ad02c76fce8c94292d3ce..b1b922928ae84f0c95bc671c8e69f69ef92897e2 100644 --- a/src/TrackingNetworkManager.cpp +++ b/src/TrackingNetworkManager.cpp @@ -36,31 +36,14 @@ 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 - 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); @@ -121,38 +104,33 @@ 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 + 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"); - 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); - } + + 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); } @@ -190,20 +168,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 bbbdeb69f35b8bf52def8e9b8102bf9090705568..bf5d09c624a682a5c73759babe81bc2203ac8151 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 @@ -37,12 +36,11 @@ public: void sendTrackingData(const SkeletonFinder& skeletonFinder); void sendSkeletonData(const Skeleton& skeleton); + void sendMultipleSkeletonsAlert(); void sendMessageToTrackingClients(ofxOscMessage _msg); void checkTrackingClients(long _currentMillis); int getTrackingClientIndex(string _ip, int _port); - - void sendBroadCastAddress(); string getOscMsgAsString(ofxOscMessage m); @@ -52,10 +50,6 @@ public: string mDeviceSerial; - float scale; - - long frameNumber; - //---------------------------------------- // Server side: ofxOscReceiver serverReceiver; // OSC receiver @@ -86,10 +80,6 @@ public: ofParameter listeningPort; ofParameter mServerID; - - ofParameterGroup streamingGuiGroup; - - ofParameter streamingWholeBody; };