Exemple #1
0
        public static Kinect2SBodyFrame MakeInstance(double timestamp, Body[] bodies)
        {
            Kinect2SBodyFrame serializableBodyFrame = new Kinect2SBodyFrame();

            serializableBodyFrame.Timestamp = timestamp;
            serializableBodyFrame.Bodies    = new List <Kinect2SBody>();
            foreach (Body body in bodies)
            {
                if (body.IsTracked)
                {
                    serializableBodyFrame.Bodies.Add(Kinect2SBody.MakeInstance(body));
                }
            }
            return(serializableBodyFrame);
        }
Exemple #2
0
        public static byte[] Serialize(double timestamp, Body[] bodies)
        {
            Kinect2SBodyFrame serializableBodyFrame = Kinect2SBodyFrame.MakeInstance(timestamp, bodies);
            BinaryFormatter   bf = new BinaryFormatter();

            try
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    bf.Serialize(ms, serializableBodyFrame);
                    return(ms.ToArray());
                }
            }
            catch (SerializationException e)
            {
                System.Diagnostics.Debug.WriteLine("Kinect2Serialization exception!!");
                System.Diagnostics.Debug.WriteLine(e.Message);
                System.Diagnostics.Debug.WriteLine(e.StackTrace);
                return(new byte[] { });
            }
        }