Esempio n. 1
0
        protected override void Kinect_NewSkeletonFrame(Skel skeletonImage)
        {
            base.Kinect_NewSkeletonFrame(skeletonImage);

            if (NewCompressedSkeletonFrame != null)
            {
                Compression<SkeletonFrame> comp = new Compression<SkeletonFrame>();
                byte[] compressedVal = comp.GzipCompress(skeletonImage.Skeleton);
                NewCompressedSkeletonFrame(compressedVal, skeletonImage.Skeleton);
            }
        }
Esempio n. 2
0
        protected override void Kinect_NewSkeletonFrame(Skel skeletonImage)
        {
            base.Kinect_NewSkeletonFrame(skeletonImage);

            if(this.Options.StoreSkeleton)
            {
                this.SkeletonFrames.Enqueue(skeletonImage.Skeleton);
                if(this.SkeletonFrames.Count > this.Options.SkeltonMax)
                {
                    SkeletonFrame dead;
                    this.SkeletonFrames.TryDequeue(out dead);
                }
            }
        }
Esempio n. 3
0
 protected virtual void Kinect_NewSkeletonFrame(Skel skeletonImage)
 {
 }
Esempio n. 4
0
        private Polyline getBodySegment(Skel skel, Skeleton data, Brush brush, Canvas canvas, params JointType[] ids)
        {
            PointCollection points = new PointCollection(ids.Length);
            for (int i = 0; i < ids.Length; ++i)
            {
                Joint j = skel.findJoint(data, ids[i]);
                points.Add(getDisplayPosition(j, canvas));
            }

            Polyline polyline = new Polyline();
            polyline.Points = points;
            polyline.Stroke = brush;
            polyline.StrokeThickness = 5;
            return polyline;
        }
Esempio n. 5
0
        private void m_kinect_NewSkeletonFrame(Skel skel)
        {
            //KinectSDK TODO: this shouldn't be needed, but if power is removed from the Kinect, you may still get an event here, but skeletonFrame will be null.
            if (skel == null)
            {
                return;
            }

            int iSkeleton = 0;
            Brush[] brushes = new Brush[6];
            brushes[0] = new SolidColorBrush(Color.FromRgb(255, 0, 0));
            brushes[1] = new SolidColorBrush(Color.FromRgb(0, 255, 0));
            brushes[2] = new SolidColorBrush(Color.FromRgb(64, 255, 255));
            brushes[3] = new SolidColorBrush(Color.FromRgb(255, 255, 64));
            brushes[4] = new SolidColorBrush(Color.FromRgb(255, 64, 255));
            brushes[5] = new SolidColorBrush(Color.FromRgb(128, 128, 255));

            Canvas skeletonCanvas = new Canvas();

            skeletonCanvas.Children.Clear();
            skeletonCanvas.Height = 300;
            skeletonCanvas.Width = 400;
            skeletonCanvas.Background = new SolidColorBrush(Color.FromRgb(138, 168, 255));

            foreach (Skeleton data in skel.SkeletonData)
            {
                if (SkeletonTrackingState.Tracked == data.TrackingState)
                {
                    // Draw bones
                    Brush brush = brushes[iSkeleton % brushes.Length];
                    skeletonCanvas.Children.Add(getBodySegment(skel,data, brush, skeletonCanvas, JointType.HipCenter, JointType.Spine, JointType.ShoulderCenter, JointType.Head));
                    skeletonCanvas.Children.Add(getBodySegment(skel,data, brush, skeletonCanvas, JointType.ShoulderCenter, JointType.ShoulderLeft, JointType.ElbowLeft, JointType.WristLeft, JointType.HandLeft));
                    skeletonCanvas.Children.Add(getBodySegment(skel,data, brush, skeletonCanvas, JointType.ShoulderCenter, JointType.ShoulderRight, JointType.ElbowRight, JointType.WristRight, JointType.HandRight));
                    skeletonCanvas.Children.Add(getBodySegment(skel,data, brush, skeletonCanvas, JointType.HipCenter, JointType.HipLeft, JointType.KneeLeft, JointType.AnkleLeft, JointType.FootLeft));
                    skeletonCanvas.Children.Add(getBodySegment(skel,data, brush, skeletonCanvas, JointType.HipCenter, JointType.HipRight, JointType.KneeRight, JointType.AnkleRight, JointType.FootRight));

                    // Draw joints
                    foreach (Joint joint in data.Joints)
                    {
                        Point jointPos = getDisplayPosition(joint, skeletonCanvas);
                        Line jointLine = new Line();
                        jointLine.X1 = jointPos.X - 3;
                        jointLine.X2 = jointLine.X1 + 6;
                        jointLine.Y1 = jointLine.Y2 = jointPos.Y;
                        jointLine.Stroke = jointColors[joint.JointType];
                        jointLine.StrokeThickness = 6;
                        skeletonCanvas.Children.Add(jointLine);
                    }
                }
                iSkeleton++;
            } // for each skeleton

            this.Canvas = skeletonCanvas;
        }
Esempio n. 6
0
 private void Kinect_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
 {
     if (this.NewSkeletonFrame != null)
     {
         using (SkeletonFrame skelFrame = e.OpenSkeletonFrame())
         {
             if (skelFrame != null)
             {
                 Skel skel = new Skel(skelFrame);
                 this.NewSkeletonFrame(skel);
                 this.SkeletonFPS.hit();
             }
         }
     }
 }