コード例 #1
0
        /// <summary>
        /// Start listening on specified port and adding data to the BlockingCollection
        /// </summary>
        /// <param name="threadInfos">Thread informations - connection params</param>
        override protected void StartListening(object threadInfos)
        {
            UdpThreadInfos <Skeleton> ti = (UdpThreadInfos <Skeleton>)threadInfos;

            Console.WriteLine("UdpSkeletonListener thread started");

            _udp = new UdpClient(ti.Port);
            IPEndPoint remoteEP = new IPEndPoint(IPAddress.Any, ti.Port);

            while (true)
            {
                // Receiving frames from KinectStreamer
                byte[] data = null;
                try
                {
                    data = _udp.Receive(ref remoteEP);
                } catch (Exception ex)
                {
                }
                int count = 0;
                // Processing Skeleton
                Skeleton skeleton = new Skeleton()
                {
                    Timestamp      = BitConverter.ToInt64(data, 0),
                    Tag            = data[8],
                    SkeletonPoints = new List <SkeletonPoint>()
                };
                count = 9;
                while (count < 409)
                {
                    // Processing SkeletonPoints
                    SkeletonPoint skeletonPoint = new SkeletonPoint();
                    skeletonPoint.X   = BitConverter.ToSingle(data, count);
                    count            += 4;
                    skeletonPoint.Y   = BitConverter.ToSingle(data, count);
                    count            += 4;
                    skeletonPoint.Z   = BitConverter.ToSingle(data, count);
                    count            += 4;
                    skeletonPoint.R   = data[count];
                    count            += 1;
                    skeletonPoint.G   = data[count];
                    count            += 1;
                    skeletonPoint.B   = data[count];
                    count            += 1;
                    skeletonPoint.Tag = data[count];
                    count            += 1;
                    skeleton.SkeletonPoints.Add(skeletonPoint);
                }

                ti.DataTransferer.Add(skeleton);
            }
        }
コード例 #2
0
        private void StartListening(object threadInfos)
        {
            UdpThreadInfos ti = (UdpThreadInfos)threadInfos;

            Console.WriteLine("Thread udp démarrée");

            UdpClient udp = new UdpClient(ti._port);

            while (true)
            {
                var remoteEP = new IPEndPoint(IPAddress.Any, ti._port);
                var data     = udp.Receive(ref remoteEP);
                ti._dataTransferer.AddData(data);
                //Console.WriteLine("receive data from " + remoteEP.ToString() + " ; Lenght = " + data.Length + " ; content = " + data);
                //Console.WriteLine("dataSize : " + ti._dataTransferer.ReadData().Count);
            }
        }
コード例 #3
0
 public UdpSkeletonListener(BlockingCollection <Skeleton> dataTransferer, int port)
 {
     _udpThreadInfos = new UdpThreadInfos <Skeleton>(dataTransferer, port);
 }
コード例 #4
0
 public UdpListener(DataTransferer dataTransferer, int port)
 {
     _threadInfos = new UdpThreadInfos(dataTransferer, port);
 }