/// <summary>
        /// Maps a point in the depth image to a point in the color image.
        /// </summary>
        /// <param name="x">x coordinate in the depth image.</param>
        /// <param name="y">y coordinate in the depth image.</param>
        /// <param name="depth">correspoinding depth at (x, y).</param>
        /// <returns></returns>
        public ColorImagePoint MapDepthPointToColorPoint(int x, int y, int depth)
        {
            var dp = new DepthImagePoint()
            {
                X     = x,
                Y     = y,
                Depth = depth
            };

            return(mapper.MapDepthPointToColorPoint(dif, dp, cif));
        }
Exemple #2
0
        //DEPTH_END


        void GetCameraPoint(Skeleton first, AllFramesReadyEventArgs e)
        {
            using (DepthImageFrame depth = e.OpenDepthImageFrame())
            {
                if (depth == null || kinectSensorChooser1.Kinect == null)
                {
                    return;
                }
                CoordinateMapper cm              = new CoordinateMapper(kinectSensorChooser1.Kinect);
                DepthImagePoint  headDepthPoint  = cm.MapSkeletonPointToDepthPoint(first.Joints[JointType.Head].Position, DepthImageFormat.Resolution640x480Fps30);
                DepthImagePoint  leftDepthPoint  = cm.MapSkeletonPointToDepthPoint(first.Joints[JointType.HandLeft].Position, DepthImageFormat.Resolution640x480Fps30);
                DepthImagePoint  rightDepthPoint = cm.MapSkeletonPointToDepthPoint(first.Joints[JointType.HandRight].Position, DepthImageFormat.Resolution640x480Fps30);

                ColorImagePoint headColorPoint  = cm.MapDepthPointToColorPoint(DepthImageFormat.Resolution640x480Fps30, headDepthPoint, ColorImageFormat.RgbResolution640x480Fps30);
                ColorImagePoint leftColorPoint  = cm.MapDepthPointToColorPoint(DepthImageFormat.Resolution640x480Fps30, leftDepthPoint, ColorImageFormat.RgbResolution640x480Fps30);
                ColorImagePoint rightColorPoint = cm.MapDepthPointToColorPoint(DepthImageFormat.Resolution640x480Fps30, rightDepthPoint, ColorImageFormat.RgbResolution640x480Fps30);

                //=>  CameraPosition(headImage, headColorPoint);
                //=>  CameraPosition(leftEllipse, leftColorPoint);
                //=>  CameraPosition(rightEllipse, rightColorPoint);
            }
        }
Exemple #3
0
        public bool GetColorFromDepth(int x, int y, out Color c)
        {
            c = Color.Black;
            int cX, cY;
            CoordinateMapper cm = new CoordinateMapper(this.sensor);
            //this.sensor.GetColorPixelCoordinatesFromDepthPixel(ImageResolution.Resolution640x480, new ImageViewArea(), x/2, y/2, (short)(depthMM[x + y*w] << 3), out cX, out cY);
            ColorImagePoint colorpoint = cm.MapDepthPointToColorPoint(DepthImageFormat.Resolution640x480Fps30, new DepthImagePoint()
            {
                X = x, Y = y, Depth = depthMM[x + y * w]
            }, ColorImageFormat.RgbResolution640x480Fps30);

            //ColorImagePoint colorPoint = this.sensor.MapDepthToColorImagePoint(DepthImageFormat.Resolution640x480Fps30, x/2, y/2, (short)(depthMM[x + y*w] << 3), ColorImageFormat.RgbResolution640x480Fps30 )//, out cX, out cY); // .MapToColorImagePoint(depthPoint.X, depthPoint.Y, sensor.ColorStream.Format);

            //if (cX != -1 && colorFrameData != null && cX < w && cY < h)
            if (colorpoint.X != -1 && colorFrameData != null && colorpoint.X < w && colorpoint.Y < h)
            {
                c = colorFrameData[colorpoint.X + colorpoint.Y * w];
                return(true);
            }

            return(false);
        }
        void GetCameraPoint(Skeleton first, AllFramesReadyEventArgs e)
        {
            using (DepthImageFrame depth = e.OpenDepthImageFrame())
            {
                if (depth == null ||
                    kinectSensorChooser1.Kinect == null)
                {
                    return;
                }

                //Map a joint location to a point on the depth map
                //head
                CoordinateMapper mapper = new CoordinateMapper(sensor);

                DepthImagePoint headDepthPoint =
                    mapper.MapSkeletonPointToDepthPoint(first.Joints[JointType.Head].Position, DepthImageFormat.Resolution640x480Fps30);
                //left hand
                DepthImagePoint leftDepthPoint =
                     mapper.MapSkeletonPointToDepthPoint(first.Joints[JointType.HandLeft].Position, DepthImageFormat.Resolution640x480Fps30);
                //right hand
                DepthImagePoint rightDepthPoint =
                     mapper.MapSkeletonPointToDepthPoint(first.Joints[JointType.HandRight].Position, DepthImageFormat.Resolution640x480Fps30);

                //Map a depth point to a point on the color image
                //head
                ColorImagePoint headColorPoint =
                    mapper.MapDepthPointToColorPoint(DepthImageFormat.Resolution640x480Fps30, headDepthPoint, ColorImageFormat.RgbResolution640x480Fps30);
                //left hand
                ColorImagePoint leftColorPoint =
                    mapper.MapDepthPointToColorPoint(DepthImageFormat.Resolution640x480Fps30, leftDepthPoint,
                    ColorImageFormat.RgbResolution640x480Fps30);
                //right hand
                ColorImagePoint rightColorPoint =
                    mapper.MapDepthPointToColorPoint(DepthImageFormat.Resolution640x480Fps30, rightDepthPoint,
                    ColorImageFormat.RgbResolution640x480Fps30);

                SkeletonPoint rightHand = first.Joints[JointType.HandRight].Position;
                SkeletonPoint leftHand = first.Joints[JointType.HandLeft].Position;

                if (isInBoundingBox(rightHand))
                {
                    CameraPosition(rightEllipse, rightColorPoint);
                    RightBlobs.Points.Add(new System.Windows.Point(rightColorPoint.X, rightColorPoint.Y));
                    //drawBlob(rightColorPoint);
                    tuioManager.addPoint(0, new PointF(rightColorPoint.X, rightColorPoint.Y));
                }
                else
                {
                    rightColorPoint.X = 0; rightColorPoint.Y = 0;
                    CameraPosition(rightEllipse, rightColorPoint);
                }

                if (isInBoundingBox(leftHand))
                {
                    CameraPosition(leftEllipse, leftColorPoint);
                    LeftBlobs.Points.Add(new System.Windows.Point(leftColorPoint.X, leftColorPoint.Y));
                    //drawBlob(leftColorPoint);
                    tuioManager.addPoint(1, new PointF(leftColorPoint.X, leftColorPoint.Y));
                }
                else
                {
                    leftColorPoint.X = 0; leftColorPoint.Y = 0;
                    CameraPosition(leftEllipse, leftColorPoint);
                }

                //Console.WriteLine("X " + rightHand.X + "Y " + rightHand.Y + "Z " + rightHand.Z);
                label1.Content = "X " + rightHand.X + "Y " + rightHand.Y + "Z " + rightHand.Z;

            }
        }
        //DEPTH_END
        void GetCameraPoint(Skeleton first, AllFramesReadyEventArgs e)
        {
            using (DepthImageFrame depth = e.OpenDepthImageFrame())
              {
                  if (depth == null || kinectSensorChooser1.Kinect == null)
                  {
                      return;
                  }
                  CoordinateMapper cm = new CoordinateMapper(kinectSensorChooser1.Kinect);
                  DepthImagePoint headDepthPoint = cm.MapSkeletonPointToDepthPoint(first.Joints[JointType.Head].Position,DepthImageFormat.Resolution640x480Fps30);
                  DepthImagePoint leftDepthPoint = cm.MapSkeletonPointToDepthPoint(first.Joints[JointType.HandLeft].Position, DepthImageFormat.Resolution640x480Fps30);
                  DepthImagePoint rightDepthPoint = cm.MapSkeletonPointToDepthPoint(first.Joints[JointType.HandRight].Position, DepthImageFormat.Resolution640x480Fps30);

                  ColorImagePoint headColorPoint =  cm.MapDepthPointToColorPoint(DepthImageFormat.Resolution640x480Fps30, headDepthPoint, ColorImageFormat.RgbResolution640x480Fps30);
                  ColorImagePoint leftColorPoint = cm.MapDepthPointToColorPoint(DepthImageFormat.Resolution640x480Fps30, leftDepthPoint, ColorImageFormat.RgbResolution640x480Fps30);
                  ColorImagePoint rightColorPoint = cm.MapDepthPointToColorPoint(DepthImageFormat.Resolution640x480Fps30, rightDepthPoint, ColorImageFormat.RgbResolution640x480Fps30);

                //=>  CameraPosition(headImage, headColorPoint);
                //=>  CameraPosition(leftEllipse, leftColorPoint);
                //=>  CameraPosition(rightEllipse, rightColorPoint);
              }
        }