Esempio n. 1
0
 static void Main(string[] args)
 {
     int commandPort = args.Length > 0 ? int.Parse(args.First()) : 10500;
     RemoteTCPSlave tcp = new RemoteTCPSlave(commandPort);
     CancellationTokenSource ender = new CancellationTokenSource();
     Console.WriteLine("Ctrl-C to exit!");
     Console.CancelKeyPress += (o, e) =>
     {
         ender.Cancel();
     };
     KinectSensor sensor = KinectSensor.KinectSensors.First(s => s.Status == KinectStatus.Connected);
     sensor.Start();
     Task proc = tcp.ProcessIncomingClients(ender.Token);
     while (!ender.IsCancellationRequested)
     {
         if (proc.IsCompleted)
             proc = tcp.ProcessIncomingClients(ender.Token);
         HandleDepthStreams(tcp, sensor);
         HandleColorStreams(tcp, sensor);
         HandleSkeletonStreams(tcp, sensor);
         Thread.Yield();
     }
     tcp.Close();
 }
Esempio n. 2
0
 static void HandleDepthStreams(RemoteTCPSlave tcp, KinectSensor sensor)
 {
     NetworkStream[] streams = tcp[Commands.Depth80];
     Commands command = Commands.Depth80;
     if (streams.Length == 0)
     {
         streams = tcp[Commands.Depth320];
         if (streams.Length == 0)
         {
             streams = tcp[Commands.Depth640];
             if (streams.Length == 0)
                 return;
             else
                 command = Commands.Depth640;
         }
         else
             command = Commands.Depth320;
     }
     Enable(sensor, command);
     SendDepth(sensor, streams, command);
 }
Esempio n. 3
0
 static void HandleSkeletonStreams(RemoteTCPSlave tcp, KinectSensor sensor)
 {
     var streams = tcp[Commands.Skeleton];
     if (streams.Length == 0)
         return;
     Enable(sensor, Commands.Skeleton);
     SendSkeleton(sensor, streams, Commands.Skeleton);
 }
Esempio n. 4
0
 static void HandleColorStreams(RemoteTCPSlave tcp, KinectSensor sensor)
 {
     NetworkStream[] streams = tcp[Commands.Color640];
     Commands command = Commands.Color640;
     if (streams.Length == 0)
     {
         streams = tcp[Commands.Color1280];
         if (streams.Length == 0)
         {
             return;
         }
         else
             command = Commands.Color1280;
     }
     Enable(sensor, command);
     SendColor(sensor, streams, command);
 }