コード例 #1
0
ファイル: GraphKinect.cs プロジェクト: ogrishman/GraphicBox
        public static int GetPersonID(int x, int y, MapToCamera camera)
        {
            if (myKin != null && x >= 0 && y >= 0)
            {
                EnableDepthStream();
                EnableSkeletonStream();
                switch (camera)
                {
                case MapToCamera.Depth:
                    if (DepthMap != null)
                    {
                        return((DepthMap[y * myKin.DepthStream.FrameWidth + x].PlayerIndex) - 1);
                    }
                    break;

                case MapToCamera.Color:
                    if (!colorNeeded)
                    {
                        colorNeeded = true;
                    }
                    if (DepthMappedToColor != null)
                    {
                        return((DepthMappedToColor[x, y].PlayerIndex) - 1);
                    }
                    break;
                }
            }
            return(-1);
        }
コード例 #2
0
ファイル: GraphKinect.cs プロジェクト: ogrishman/GraphicBox
        public static void getjoint(int SkeletonID, MapToCamera camera, BodyParts joint, out int x, out int y, out int z, bool sortID)
        {
            x = y = z = -1;
            if (myKin != null)
            {
                EnableSkeletonStream();

                if (_skeletons != null)
                {
                    if (sortID)
                    {
                        SkeletonID = _SelectTrackingSkeleton(SkeletonID);
                    }

                    if (SkeletonID != -1)
                    {
                        if (_skeletons[SkeletonID] != null)
                        {
                            SkeletonPoint point = _skeletons[SkeletonID].Joints[(JointType)joint].Position;
                            if (point.X != 0 && point.Y != 0 && point.Z != 0)
                            {
                                switch (camera)
                                {
                                case MapToCamera.Metric:
                                    x = Convert.ToInt32(point.X * 1000f);
                                    y = Convert.ToInt32(point.Y * 1000f);
                                    z = Convert.ToInt32(point.Z * 1000f);
                                    break;

                                case MapToCamera.Depth:
                                    DepthImagePoint dPoint0 = myKin.CoordinateMapper.MapSkeletonPointToDepthPoint(point, myKin.DepthStream.Format);
                                    x = dPoint0.X;
                                    y = dPoint0.Y;
                                    z = dPoint0.Depth;
                                    break;

                                case MapToCamera.Color:
                                    ColorImagePoint cPoint  = myKin.CoordinateMapper.MapSkeletonPointToColorPoint(point, myKin.ColorStream.Format);
                                    DepthImagePoint dPoint1 = myKin.CoordinateMapper.MapSkeletonPointToDepthPoint(point, myKin.DepthStream.Format);
                                    x = cPoint.X;
                                    y = cPoint.Y;
                                    z = dPoint1.Depth;
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: GraphKinect.cs プロジェクト: ogrishman/GraphicBox
        public static int GetDepthPixel(int x, int y, MapToCamera camera)
        {
            if (myKin != null && x >= 0 && y >= 0)
            {
                EnableDepthStream();

                switch (camera)
                {
                case MapToCamera.Depth:
                    if (DepthMap != null)
                    {
                        return(DepthMap[y * myKin.DepthStream.FrameWidth + x].Depth);
                    }
                    break;

                case MapToCamera.Color:
                    if (!colorNeeded)
                    {
                        colorNeeded = true;
                    }
                    if (DepthMappedToColor != null)
                    {
                        return(DepthMappedToColor[x, y].Depth);
                    }
                    break;

                case MapToCamera.Metric:
                    if (!metricNeeded)
                    {
                        metricNeeded = true;
                    }
                    if (DepthMappedToMetric != null)
                    {
                        return(DepthMappedToMetric[x, y].Depth);
                    }
                    break;
                }
            }
            return(-1);
        }
コード例 #4
0
ファイル: GraphKinect.cs プロジェクト: ogrishman/GraphicBox
 public static void getjoint(int SkeletonID, MapToCamera camera, BodyParts joint, out int x, out int y, out int z)
 {
     getjoint(SkeletonID, camera, joint, out x, out y, out z, true);
 }