public Human(double x, double y, double width, double height, double frameWidth, double frameHeight)
 {
     BL           = RelativePoint.FromFrame(new Point(x, y + height), frameWidth, frameHeight);
     TL           = RelativePoint.FromFrame(new Point(x, y), frameWidth, frameHeight);
     TR           = RelativePoint.FromFrame(new Point(x + width, y), frameWidth, frameHeight);
     BR           = RelativePoint.FromFrame(new Point(x + width, y + height), frameWidth, frameHeight);
     Center       = RelativePoint.FromFrame(new Point(x + width / 2, y + height / 2), frameWidth, frameHeight);
     BottomCenter = RelativePoint.FromFrame(new Point(x + width / 2, y + height), frameWidth, frameHeight);
 }
        public RelativePoint Perspective(Point2d point)
        {
            // Evaluate the homographic transform
            double x         = point.X / TopBottomDistance;
            double y         = point.Y / LeftRightDistance;
            double T         = g * x + h * y + 1;
            var    normPoint = new Point((a * x + b * y) / (double)T + p[0].X, (d * x + e * y) / (double)T + p[0].Y);

            return(RelativePoint.FromNorm(normPoint, session.FrameSource.Width, session.FrameSource.Height));
        }
        public Point2d?Perspective(RelativePoint point)
        {
            if (!GeometryHelpers.IsInside(point, BL, TL, TR, BR))
            {
                return(null);
            }

            double px = p[0].X;
            double py = p[0].Y;
            double xp = point.Norm.X;
            double yp = point.Norm.Y;

            double detD  = ((a + g * px - g * xp) * (e + h * py - h * yp)) - ((d + g * py - g * yp) * (b + h * px - h * xp));
            double detDx = ((xp - px) * (e + h * py - h * yp)) - ((yp - py) * (b + h * px - h * xp));
            double detDy = ((a + g * px - g * xp) * (yp - py)) - ((d + g * py - g * yp) * (xp - px));

            double x = detDx / detD;
            double y = detDy / detD;

            double normX = x * TopBottomDistance;
            double normY = y * LeftRightDistance;

            return(new Point2d(normX, normY));
        }