Inheritance: ISkeletonFrame
Exemplo n.º 1
0
        private void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            try
            {
                KinectSkeletonFrame skeletonFrame = new KinectSkeletonFrame(e.OpenSkeletonFrame());
                Console.WriteLine("\tSkeletonFrame.FrameNumber: {0}", skeletonFrame.FrameNumber);
                newSkeletonFrame = true;

                List <SkeletonReceiver> sickListeners = new List <SkeletonReceiver>();
                // This would be more stable if implemented using a thread pool and a queue, but for
                // a handful of clients this shouldn't be an issue;
                List <SkeletonReceiver> listenersCopy;
                lock (listeners)
                {
                    listenersCopy = listeners.ToList();
                }
                foreach (SkeletonReceiver listener in listenersCopy)
                {
                    try
                    {
                        listener.receiveFrame(skeletonFrame);
                    }
                    catch
                    {
                        Console.WriteLine("A Kinect client caused an error and will no longer receive messages.");
                        sickListeners.Add(listener);
                    }
                }
                foreach (SkeletonReceiver sickListener in sickListeners)
                {
                    listeners.Remove(sickListener);
                }
            }
            catch (Exception ex) { Console.WriteLine("Failed in nui_SkeletonFrameReady"); Console.WriteLine(ex.StackTrace); }
        }
        public void receiveFrame(KinectSkeletonFrame frame)
        {
            if (!running)
            {
                return;           // unregistering ourselves is no guarantee that we are not going to get called for a couple of frames
            }
            Send(frame);
            ++framesGot;

            // Either add a comma if there is more data remaining, or finish up
            if (framesToGet > framesGot)
            {
                SendString(",");
            }
            else
            {
                Disconnect();
            }
        }
        private void Send(KinectSkeletonFrame skeletonFrame)
        {
            String buffer;

            if (skeletonFrame != null)
            {
                try
                {
                    // TODO: get the callback string from the URL prams
                    buffer = skeletonFrame.toJSON();
                    SendString(buffer);
                }
                catch (Exception e)
                {
                    Console.WriteLine("Failed to Send\n{0}", e.Message);
                    throw e;
                }
            }
            else
            {
                Console.WriteLine("SkeletonFrame not ready");
            }
        }
 private void Send(KinectSkeletonFrame skeletonFrame)
 {
     String buffer;
     if (skeletonFrame != null)
     {
         try
         {
             // TODO: get the callback string from the URL prams
             buffer = skeletonFrame.toJSON();
             SendString(buffer);
         }
         catch (Exception e)
         {
             Console.WriteLine("Failed to Send\n{0}", e.Message);
             throw e;
         }
     }
     else
     {
         Console.WriteLine("SkeletonFrame not ready");
     }
 }
        public void receiveFrame(KinectSkeletonFrame frame)
        {
            if (!running) return; // unregistering ourselves is no guarantee that we are not going to get called for a couple of frames
            Send(frame);
            ++framesGot;

            // Either add a comma if there is more data remaining, or finish up
            if (framesToGet > framesGot) SendString(",");
            else Disconnect();
        }
        private void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            try
            {
                KinectSkeletonFrame skeletonFrame = new KinectSkeletonFrame(e.OpenSkeletonFrame());
                Console.WriteLine("\tSkeletonFrame.FrameNumber: {0}", skeletonFrame.FrameNumber);
                newSkeletonFrame = true;

                List<SkeletonReceiver> sickListeners = new List<SkeletonReceiver>();
                // This would be more stable if implemented using a thread pool and a queue, but for
                // a handful of clients this shouldn't be an issue;
                List<SkeletonReceiver> listenersCopy;
                lock (listeners)
                {
                    listenersCopy = listeners.ToList();
                }
                foreach (SkeletonReceiver listener in listenersCopy)
                {
                    try
                    {
                        listener.receiveFrame(skeletonFrame);
                    }
                    catch
                    {
                        Console.WriteLine("A Kinect client caused an error and will no longer receive messages.");
                        sickListeners.Add(listener);
                    }
                }
                foreach (SkeletonReceiver sickListener in sickListeners)
                {
                    listeners.Remove(sickListener);
                }
            }
            catch (Exception ex) { Console.WriteLine("Failed in nui_SkeletonFrameReady"); Console.WriteLine(ex.StackTrace); }
        }
 public void receiveFrame(KinectSkeletonFrame frame)
 {
     lock (frames) frames.AddLast(frame);
 }
 public void receiveFrame(KinectSkeletonFrame frame)
 {
     lock (frames) frames.AddLast(frame);
 }