public void Initialize() { var kinectParams = HandInputParams.GetKinectParams( Properties.Resources.ColorToDepthRelationalParameters); converter = new CoordinateConverter(new CoordinateMapper(kinectParams), HandInputParams.ColorImageFormat, HandInputParams.DepthImageFormat); }
public SimpleSkeletonHandTracker(int width, int height, CoordinateMapper coordMapper, int bufferSize = 1) { mapper = new CoordinateConverter(coordMapper, HandInputParams.ColorImageFormat, HandInputParams.DepthImageFormat); Init(width, height); }
/// <summary> /// Computes the head circle in the depth image. /// </summary> /// <param name="skeleton"></param> /// <param name="mapper"></param> /// <returns></returns> public static FaceModel GetFaceModel(Skeleton skeleton, CoordinateConverter mapper) { var headJointPos = GetJoint(skeleton, JointType.Head).Position; var shoulderCenterJoint = GetJoint(skeleton, JointType.ShoulderCenter); var headDepthPt = mapper.MapSkeletonPointToDepthPoint(headJointPos); var shoulderDepthPt = mapper.MapSkeletonPointToDepthPoint(shoulderCenterJoint.Position); var radius = Math.Abs(shoulderDepthPt.Y - headDepthPt.Y) / 2; return new FaceModel(GeometryUtil.Midpoint(headDepthPt, shoulderDepthPt), radius); }
public PlayerDetector(int width, int height, CoordinateConverter mapper, int bufferSize = 1) { this.width = width; this.height = height; this.mapper = mapper; DepthPlayerMask = new Image <Gray, Byte>(width, height); ColorPlayerMask = new Image <Gray, Byte>(width, height); DepthImage = new Image <Gray, Byte>(width, height); dataBuffer = new DataBuffer(bufferSize); }
public PlayerDetector(int width, int height, CoordinateConverter mapper, int bufferSize = 1) { this.width = width; this.height = height; this.mapper = mapper; DepthPlayerMask = new Image<Gray, Byte>(width, height); ColorPlayerMask = new Image<Gray, Byte>(width, height); DepthImage = new Image<Gray, Byte>(width, height); dataBuffer = new DataBuffer(bufferSize); }
/// <summary> /// Computes the head circle in the depth image. /// </summary> /// <param name="skeleton"></param> /// <param name="mapper"></param> /// <returns></returns> public static FaceModel GetFaceModel(Skeleton skeleton, CoordinateConverter mapper) { var headJointPos = GetJoint(skeleton, JointType.Head).Position; var shoulderCenterJoint = GetJoint(skeleton, JointType.ShoulderCenter); var headDepthPt = mapper.MapSkeletonPointToDepthPoint(headJointPos); var shoulderDepthPt = mapper.MapSkeletonPointToDepthPoint(shoulderCenterJoint.Position); var radius = Math.Abs(shoulderDepthPt.Y - headDepthPt.Y) / 2; return(new FaceModel(GeometryUtil.Midpoint(headDepthPt, shoulderDepthPt), radius)); }
public static SkeletonPoint DepthToSkeleton(Rectangle rect, byte[,,] depthData, int width, int height, CoordinateConverter mapper) { var aveDepth = 0.0; var count = 0; for (int y = rect.Top; y < rect.Top + rect.Height && y < height; y++) for (int x = rect.Left; x < rect.Left + rect.Width && x < width; x++) { if (x > 0 && y > 0) { aveDepth += depthData[y, x, 0]; count++; } } var depth = PlayerDetector.ToWorldDepth(aveDepth / count); var center = rect.Center(); var centerX = Math.Max(0, center.X); centerX = Math.Min(centerX, width); var centerY = Math.Max(0, center.Y); centerY = Math.Min(centerY, height); return mapper.MapDepthPointToSkeletonPoint((int)centerX, (int)centerY, depth); }
public SalienceHandTracker(int width, int height, CoordinateMapper mapper, int bufferSize = 1) { this.mapper = new CoordinateConverter(mapper, HandInputParams.ColorImageFormat, HandInputParams.DepthImageFormat); Init(width, height, bufferSize); }
/// <summary> /// Creates a detector based on salience. /// </summary> /// <param name="width"></param> /// <param name="height"></param> /// <param name="kinectParamsBinary">Kinect parameters in binary.</param> public SalienceHandTracker(int width, int height, Byte[] kinectParams, int bufferSize = 1) { mapper = new CoordinateConverter(kinectParams, HandInputParams.ColorImageFormat, HandInputParams.DepthImageFormat); Init(width, height, bufferSize); }
public StipHandTracker(int width, int height, CoordinateMapper coordMapper) { mapper = new CoordinateConverter(coordMapper, HandInputParams.ColorImageFormat, HandInputParams.DepthImageFormat); Init(width, height); }
public StipHandTracker(int width, int height, Byte[] kinectParams) { mapper = new CoordinateConverter(kinectParams, HandInputParams.ColorImageFormat, HandInputParams.DepthImageFormat); Init(width, height); }
public static void AlignImageColorToDepth(Image <Gray, Byte> colorImg, Image <Gray, Byte> alignedImg, short[] depthFrame, CoordinateConverter mapper) { var width = alignedImg.Width; var height = alignedImg.Height; alignedImg.ROI = colorImg.ROI; CvInvoke.cvZero(alignedImg.Ptr); var data = colorImg.Data; var alignedData = alignedImg.Data; var roiWidth = width; var roidHeight = height; var roi = colorImg.ROI; if (!roi.IsEmpty) { roiWidth = roi.Width; roidHeight = roi.Height; } for (int r = roi.Top; r < roi.Top + roidHeight; r++) { for (int c = roi.Left; c < roi.Left + roiWidth; c++) { var depthPixel = depthFrame[r * width + c]; var depth = DepthUtil.RawToDepth(depthPixel); var cp = mapper.MapDepthPointToColorPoint(c, r, depth); if (cp.X >= 0 && cp.X < width && cp.Y >= 0 && cp.Y < height) { alignedData[r, c, 0] = data[cp.Y, cp.X, 0]; } } } CvInvoke.cvMorphologyEx(alignedImg.Ptr, alignedImg.Ptr, IntPtr.Zero, IntPtr.Zero, CV_MORPH_OP.CV_MOP_CLOSE, 1); alignedImg.ROI = drawing.Rectangle.Empty; }