Exemplo n.º 1
0
 /// <summary>
 /// Call Core Track Algo and Smooth Algo to Track and Smooth FingerTips
 /// </summary>
 /// <param name="timeStamp"></param>
 public void DetectAndSmooth(int timeStamp)
 {
     if(null == sensor) 
         return;
     RightHand.FingerDetect(0);
     CoordinateMapperPlus mapper = new CoordinateMapperPlus (this.sensor);
     List<PointSkeleton3D> currFingerTips = mapper.MapDepthPointsToSketelonPoints(sensor.DepthStream.Format, RightHand.FingerTips);
     smoother.Smooth(currFingerTips,timeStamp);
 }
Exemplo n.º 2
0
 public Point2D GetPoint2Position(FingerType id)
 {
     if (this[id].TrackingState == FingerTrackingState.Tracked)
     {
         CoordinateMapperPlus mapper = new CoordinateMapperPlus(this.sensor);
         return mapper.MapSkeletonPointToColorPoint(this[id].Position, this.sensor.ColorStream.Format);
     }
     return new Point2D();
 }
Exemplo n.º 3
0
        void Sensor_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
        {
            if (!skeletonReadyFlag || CurrViewType != ViewEnum.CameraView)     //return if no person is detected
                return;
            using (DepthImageFrame depthFrame = e.OpenDepthImageFrame())
            {
                if (depthFrame != null)
                {
                    depthFrame.CopyDepthImagePixelDataTo(this.depthPixels);

                    CoordinateMapperPlus mapper = new CoordinateMapperPlus(this.Sensor);
                    PointDepth3D leftDepth3D = mapper.MapSkeletonPointToDepthPoint(leftHand, this.Sensor.DepthStream.Format);
                    PointDepth3D rightDepth3D = mapper.MapSkeletonPointToDepthPoint(rightHand, this.Sensor.DepthStream.Format);

                    int index = rightDepth3D.Y * DepthFrameWidth + rightDepth3D.X;
                    if (index < 0 || index > this.depthPixels.Length)
                        return;
                    short currDepth = depthPixels[index].Depth;

                    int indexColor = 0;
                    int rectSize = 0;
                    for (int i = 0; i < this.DepthFrameWidth; i++)
                    {
                        for (int j = 0; j < this.DepthFrameHeight; j++)
                        {
                            indexColor = (j * this.DepthFrameWidth + i) * 4;
                            if (KinectUtil.isInTrackRegion(i, j, rightDepth3D.X, rightDepth3D.Y))
                            {
                                int indexDepthPixels = j * this.DepthFrameWidth + i;
                                rectDepth3D[rectSize++] = new PointDepth3D(i, j, depthPixels[indexDepthPixels].Depth);

                            }
                        }
                    }
                    if (rectSize == rectWidth * rectHeight)
                    {
                        detector.RightHand = new Hand(rectDepth3D, rightDepth3D, rectWidth, rectHeight);
                        detector.DetectAndSmooth(timeStamp);

                        Fingers.Identify3(this.Sketelon3DFingerTips, timeStamp);
                        timeStamp = (++timeStamp) % KinectUtil.LOOP_TIMES;
                    }

                    this.DepthBitmap.WritePixels(
                         new Int32Rect(0, 0, this.DepthBitmap.PixelWidth, this.DepthBitmap.PixelHeight),
                         this.depthColor,
                         this.DepthBitmap.PixelWidth * sizeof(int),
                         0);

                }
            }
        }