예제 #1
0
        static void LogKinectData(KinectBag <KinectBody> bundle)
        {
            Console.WriteLine("{0} New bundle from {1} ", DateTime.UtcNow.ToFileTimeUtc(), bundle.SensorId);
            if (bundle.Items != null)
            {
                Console.WriteLine("Bundle contains {0} bodies", bundle.Items.Count);
                foreach (var body in bundle.Items)
                {
                    Console.WriteLine("- Body {0}", body);
                    Console.WriteLine("- Hand States. Left {0} (Conf: {1}) Right {2} (Conf: {3})", body.HandLeftState, body.HandLeftConfidence, body.HandRightState, body.HandRightConfidence);
                    if (body.FloatData.Keys.Count > 0)
                    {
                        Console.WriteLine("- Custom Data");
                        foreach (var kv in body.FloatData)
                        {
                            Console.WriteLine("-- {0}: {1}", kv.Key, kv.Value);
                        }
                    }
#if LOG_JOINTS
                    Console.WriteLine("- Joints");
                    foreach (var joint in body.Joints)
                    {
                        Console.WriteLine("  - {0}", joint);
                    }
#endif
                }
            }
            else
            {
                Console.WriteLine("Empty bundle.");
            }
        }
        /// <summary>
        /// Called when data is ready, creates a bundle, serializes it and broadcasts it
        /// </summary>
        /// <param name="bodies">List of bodies to send</param>
        /// <param name="sensorId">Device ID for the Kinect sensor</param>
        void ProcessAndTransmit(string sensorId, List <KinectBody> bodies)
        {
            foreach (var processor in BodyProcessors)
            {
                processor.ProcessBodies(bodies);
            }
            var stuffedBodyBag = new KinectBag <KinectBody>
            {
                SensorId = sensorId,
                Items    = bodies
            };

            _messagePublisher.SerializeAndSendObject(stuffedBodyBag, "body");
        }
예제 #3
0
 static void LogKinectData(KinectBag<KinectGesture> bundle)
 {
     Console.WriteLine("{0} New bundle from {1} ", DateTime.UtcNow.ToFileTimeUtc(), bundle.SensorId);
     if (bundle.Items != null)
     {
         foreach (var item in bundle.Items)
         {
             Console.WriteLine("- {0}", item);
         }
     }
     else
     {
         Console.WriteLine("Empty bundle.");
     }
     Console.WriteLine();
 }
예제 #4
0
 static void LogKinectData(KinectBag <KinectGesture> bundle)
 {
     Console.WriteLine("{0} New bundle from {1} ", DateTime.UtcNow.ToFileTimeUtc(), bundle.SensorId);
     if (bundle.Items != null)
     {
         foreach (var item in bundle.Items)
         {
             Console.WriteLine("- {0}", item);
         }
     }
     else
     {
         Console.WriteLine("Empty bundle.");
     }
     Console.WriteLine();
 }
예제 #5
0
        /// <summary>
        /// Returns a Kinect data bag if one is ready.  WARNING: This is a blocking call.
        /// </summary>
        /// <returns>KinectBag with the received data.</returns>
        public KinectBag <T> Dequeue()
        {
            KinectBag <T> data = null;

            while (data == null)
            {
                var msg = Consumer.Pop();
                if (msg != null)
                {
                    using (var ms = new MemoryStream(msg.Body))
                    {
                        data = ProtoBuf.Serializer.Deserialize <KinectBag <T> >(ms);
                    }
                }
                else
                {
                    System.Threading.Thread.Sleep(1);
                }
            }
            return(data);
        }
 /// <summary>
 /// Called when data is ready, creates a bundle, serializes it and broadcasts it
 /// </summary>
 /// <param name="bodies">List of bodies to send</param>
 /// <param name="sensorId">Device ID for the Kinect sensor</param>
 void ProcessAndTransmit(string sensorId, List<KinectBody> bodies)
 {
     foreach (var processor in BodyProcessors)
     {
         processor.ProcessBodies(bodies);
     }
     var stuffedBodyBag = new KinectBag<KinectBody>
     {
         SensorId = sensorId,
         Items = bodies
     };
     
     _messagePublisher.SerializeAndSendObject(stuffedBodyBag, "body");
 }