Example #1
0
 public void ConfigureClient(KinectClient client, KinectStreamerConfig config)
 {
     StateObject state = clientStateObjectDictionary[client];
     ClientConfigurationMessage msg = new ClientConfigurationMessage()
     {
         Configuration = config
     };
     SerializeAndSendMessage(msg, state.WorkSocket);
 }
Example #2
0
 public void AddOrUpdateWorkspace(string workspaceId, Workspace workspace, KinectClient client)
 {
     if (!workspaceDictionary.Keys.Contains(workspaceId))
     {
         workspaceDictionary.Add(workspaceId, workspace);
         workspaceClientDictionary.Add(workspaceId, client);
     }
     else
     {
         workspaceDictionary[workspace.ID] = workspace;
     }
 }
Example #3
0
 public void AddWorkspace(Workspace workspace, KinectClient client)
 {
     StateObject state = clientStateObjectDictionary[client];
     if (state == null)
     {
         state = stateObjectClientDictionary.Keys.First();
     }
     WorkspaceMessage message = new WorkspaceMessage()
     {
         ID = workspace.ID,
         Name = workspace.Name,
         Vertices = workspace.Vertices.ToArray()
     };
     SerializeAndSendMessage(message, state.WorkSocket);
 }
 private void ProcessCalibrationDataMessage(object obj, KinectClient sender)
 {
     CalibrationDataMessage msg = (CalibrationDataMessage) obj;
     dataStore.AddCalibrationBody(sender, msg.CalibrationBody);
     if (ConfigurationMessageArrived != null)
     {
         ConfigurationMessageArrived(msg, sender);
     }
 }
Example #5
0
 private void kinectServer_TextMessageArrived(KinectDemoMessage message, KinectClient client)
 {
     Dispatcher.Invoke(() =>
     {
         //ClientMessageBox.Text += "\nFrom " + client.Name + ":\n" + ((TextMessage)message).Text;
     });
 }
Example #6
0
 private void ClientSettingsChanged(KinectClient client, KinectStreamerConfig config)
 {
     KinectServer.Instance.ConfigureClient(client, config);
 }
 private void ProcessWorkspaceMessage(object obj, KinectClient sender)
 {
     WorkspaceMessage msg = (WorkspaceMessage)obj;
     Workspace workspace = dataStore.GetWorkspace(msg.ID);
     workspace.Name = msg.Name;
     workspace.Vertices = new ObservableCollection<Point>(msg.Vertices);
     workspace.Vertices3D = msg.Vertices3D;
     workspace.VertexDepths = msg.VertexDepths;
     WorkspaceProcessor.SetWorkspaceCloudRealVerticesAndCenter(workspace, depthFrameSize);
     WorkspaceUpdated((WorkspaceMessage)obj, sender);
 }
        private void ProcessPointCloudStreamMessage(object obj, KinectClient client)
        {
            bool coloredPointCloud = false;
            PointCloudStreamMessage msg = (PointCloudStreamMessage)obj;
            if (obj is ColoredPointCloudStreamMessage)
            {
                coloredPointCloud = true;
            }

            double[] doubleArray = msg.PointCloud;
            NullablePoint3D[] pointArray = new NullablePoint3D[doubleArray.Length / 3];
            for (int i = 0; i < doubleArray.Length; i += 3)
            {
                if (double.IsNegativeInfinity(doubleArray[i]))
                {
                    pointArray[i / 3] = null;
                }
                else
                {
                    pointArray[i / 3] = new NullablePoint3D(doubleArray[i], doubleArray[i + 1], doubleArray[i + 2]);
                }
            }

            PointCloud pointCloud = new PointCloud() {Points = pointArray};
            if (coloredPointCloud)
            {
                pointCloud.ColorBytes = ((ColoredPointCloudStreamMessage) msg).ColorPixels;
            }

            dataStore.AddOrUpdatePointCloud(client, pointCloud);

            if (PointCloudMessageArrived != null)
            {
                PointCloudMessageArrived(msg, client);
            }
            if (coloredPointCloud && ColoredPointCloudMessageArrived != null)
            {
                ColoredPointCloudMessageArrived(msg, client);
            }
        }
        private void ProcessConfigurationData(object obj, KinectClient sender)
        {
            dataStore.AddOrUpdateConfiguration(sender, ((ClientConfigurationMessage) obj).Configuration);

            ClientConfigurationMessage msg = (ClientConfigurationMessage) obj;
            if (ConfigurationMessageArrived != null)
            {
                ConfigurationMessageArrived(msg, sender);
            }
        }
Example #10
0
 public NullablePoint3D[] GetPointCloudForClient(KinectClient client)
 {
     try
     {
         return clientPointCloudDictionary[client].Points;
     }
     catch
     {
         return null;
     }
 }
Example #11
0
 // Returns with the next kinect client to given currentClient in the clients list.
 // If currentClients is null, returns with first client.
 public KinectClient GetNextClient(KinectClient currentClient)
 {
     KinectClient nextClient = null;
     if (kinectClients.Count == 0)
     {
         return null;
     }
     try
     {
         if (currentClient == null)
         {
             nextClient = kinectClients[0];
         }
         else
         {
             nextClient = kinectClients[kinectClients.IndexOf(currentClient) + 1];
         }
     }
     catch (Exception)
     {
         nextClient = kinectClients[0];
     }
     return nextClient;
 }
Example #12
0
        public KinectStreamerConfig GetConfigurationForClient(KinectClient client)
        {
            try
            {
                return clientConfigurationDictionary[client];
            }
            catch (Exception)
            {

                return null;
            }
        }
Example #13
0
 public PointCloud GetColoredPointCloudForClient(KinectClient client)
 {
     return clientPointCloudDictionary[client];
 }
Example #14
0
 public List<SerializableBody> GetCalibrationBodiesForClient(KinectClient client)
 {
     return clientCalibrationBodies[client];
 }
 private void ProcessCalibrationMessage(object obj, KinectClient sender)
 {
     throw new NotImplementedException();
 }
 private void ProcessColorStreamMessage(object obj, KinectClient sender)
 {
     if (ColorMessageArrived != null)
     {
         ColorMessageArrived((ColorStreamMessage)obj, sender);
     }
 }
Example #17
0
 private KinectClient CreateClient(EndPoint endPoint)
 {
     KinectClient kinectClient;
     kinectClient = new KinectClient(endPoint);
     kinectClients.Add(kinectClient);
     clientCalibrationBodies[kinectClient] = new List<SerializableBody>();
     return kinectClient;
 }
 private void ProcessDepthStreamMessage(object obj, KinectClient sender)
 {
     if (DepthMessageArrived != null)
     {
         DepthMessageArrived((DepthStreamMessage)obj, sender);
         if (depthFrameSize == null)
         {
             depthFrameSize = ((DepthStreamMessage)obj).DepthFrameSize;
         }
     }
 }
Example #19
0
 public void AddCalibrationBody(KinectClient client, SerializableBody body)
 {
     clientCalibrationBodies[client].Add(body);
 }
 private void ProcessTextMessage(object obj, KinectClient sender)
 {
     TextMessage msg = (TextMessage)obj;
     if (TextMessageArrived != null)
     {
         TextMessageArrived(msg, sender);
     }
 }
Example #21
0
 public void AddOrUpdateConfiguration(KinectClient client, KinectStreamerConfig kinectStreamerConfig)
 {
     clientConfigurationDictionary[client] = kinectStreamerConfig;
 }
        public void ProcessStreamMessage(object obj, KinectClient sender)
        {
            if (obj == null)
            {
                return;
            }
            if (obj is KinectClientMessage)
            {
                if (obj is UnifiedStreamerMessage)
                {
                    UnifiedStreamerMessage msg = (UnifiedStreamerMessage)obj;
                    if (msg.BodyStreamMessage != null)
                    {
                        ProcessBodyStreamMessage(msg.BodyStreamMessage, sender);
                    }
                    if (msg.ColorStreamMessage != null)
                    {
                        ProcessColorStreamMessage(msg.ColorStreamMessage, sender);
                    }
                    if (msg.DepthStreamMessage != null)
                    {
                        ProcessDepthStreamMessage(msg.DepthStreamMessage, sender);
                    }
                    if (msg.PointCloudStreamMessage != null)
                    {
                        ProcessPointCloudStreamMessage(msg.PointCloudStreamMessage, sender);
                    }
                }
                else if (obj is DepthStreamMessage)
                {
                    ProcessDepthStreamMessage(obj, sender);
                }
                else if (obj is ColorStreamMessage)
                {
                    ProcessColorStreamMessage(obj, sender);
                }
                else if (obj is PointCloudStreamMessage)
                {
                    ProcessPointCloudStreamMessage(obj, sender);
                }
                else if (obj is BodyStreamMessage)
                {
                    ProcessBodyStreamMessage(obj, sender);
                }
                else if (obj is CalibrationDataMessage)
                {
                    ProcessCalibrationDataMessage(obj, sender);
                }

            }
            else if (obj is WorkspaceMessage)
            {
                ProcessWorkspaceMessage(obj, sender);
            }
            else if (obj is TextMessage)
            {
                ProcessTextMessage(obj, sender);
            }
            else if (obj is ClientConfigurationMessage)
            {
                ProcessConfigurationData(obj, sender);
            }
            else if (obj is CalibrationMessage)
            {
                ProcessCalibrationMessage(obj, sender);
            }
        }
Example #23
0
 public void AddOrUpdatePointCloud(KinectClient client, PointCloud pointCloud)
 {
     clientPointCloudDictionary[client] = pointCloud;
 }
Example #24
0
 private void kinectServer_DepthDataArrived(KinectDemoMessage message, KinectClient client)
 {
     depthFrameSize = ((DepthStreamMessage)message).DepthFrameSize;
     serverMessageProcessor.DepthMessageArrived -= kinectServer_DepthDataArrived;
 }
 private void ProcessBodyStreamMessage(object obj, KinectClient sender)
 {
     BodyStreamMessage msg = (BodyStreamMessage)obj;
     if (BodyMessageArrived != null)
     {
         BodyMessageArrived(msg, sender);
     }
 }
Example #26
0
 private void kinectServer_WorkspaceUpdated(KinectDemoMessage message, KinectClient client)
 {
     WorkspaceMessage msg = (WorkspaceMessage)message;
     cloudView.SetWorkspace(dataStore.GetWorkspace(msg.ID));
 }
Example #27
0
 private void ObjectArrived(object obj, KinectClient sender)
 {
     if (obj != null)
     {
         Debug.WriteLine("Object from " + sender.Name + " deserialized: " + obj.GetType());
     }
     serverMessageProcessor.ProcessStreamMessage(obj, sender);
 }