示例#1
0
 public Eye(Eye other)
 {
     if (null != other)
     {
         RawCoordinates = new Point2D(other.RawCoordinates);
         SmoothedCoordinates = new Point2D(other.SmoothedCoordinates);
         PupilCenterCoordinates = new Point2D(other.PupilCenterCoordinates);
         PupilSize = other.PupilSize;
     }
 }
示例#2
0
        public GazeData(GazeData other)
        {
            if (null != other)
            {
                State = other.State;
                TimeStamp = other.TimeStamp;
                TimeStampString = other.TimeStampString;

                RawCoordinates = new Point2D(other.RawCoordinates);
                SmoothedCoordinates = new Point2D(other.SmoothedCoordinates);

                LeftEye = new Eye(other.LeftEye);
                RightEye = new Eye(other.RightEye);

                IsFixated = other.IsFixated;
            }
        }
示例#3
0
 public Point2D(Point2D other)
     : this(other.x, other.y)
 {
 }
示例#4
0
 public Point2D Subtract(Point2D p2)
 {
     return new Point2D(x - p2.x, y - p2.y);
 }
示例#5
0
 public Point2D Add(Point2D p2)
 {
     return new Point2D(x + p2.x, y + p2.y);
 }
示例#6
0
        private void Set(GazeData other)
        {
            State = other.State;
            TimeStamp = other.TimeStamp;
            TimeStampString = other.TimeStampString;

            RawCoordinates = new Point2D(other.RawCoordinates);
            SmoothedCoordinates = new Point2D(other.SmoothedCoordinates);

            LeftEye = new Eye(other.LeftEye);
            RightEye = new Eye(other.RightEye);

            IsFixated = other.IsFixated;
        }
示例#7
0
 /// <summary>
 /// Clamps a gaze points within the limits of the parameter rect.
 /// </summary>
 /// <param name="gaze">gaze data frame to base calculation upon</param>
 /// <param name="dimX">x coordinate of topleft rect anchor</param>
 /// <param name="dimY">y coordinate of topleft rect anchor</param>
 /// <param name="dimWidth">dimension width to base calculation upon</param>
 /// <param name="dimHeight">dimension height to base calculation upon</param>
 /// <param name="clampMargin">extra space surrounding rect to be included</param>
 /// <returns>clamped gaze point</returns>
 public static Point2D ClampGazeToRect(Point2D gaze, int dimWidth, int dimHeight, float clampMargin)
 {
     return ClampGazeToRect(gaze, 0, 0, dimWidth, dimHeight, clampMargin, clampMargin);
 }
示例#8
0
        /// <summary>
        /// Clamps a gaze points within the limits of the parameter rect.
        /// </summary>
        /// <param name="gaze">gaze data frame to base calculation upon</param>
        /// <param name="dimX">x coordinate of topleft rect anchor</param>
        /// <param name="dimY">y coordinate of topleft rect anchor</param>
        /// <param name="dimWidth">dimension width to base calculation upon</param>
        /// <param name="dimHeight">dimension height to base calculation upon</param>
        /// <param name="clampHorsMargin">extra hors space surrounding rect to be included</param>
        /// <param name="clampVertMargin">extra vert space surrounding rect to be included</param>
        /// <returns>clamped gaze point</returns>
        public static Point2D ClampGazeToRect(Point2D gaze, int dimX, int dimY, int dimWidth, int dimHeight, float clampHorsMargin, float clampVertMargin)
        {
            Point2D clamped = new Point2D(gaze);

            if (null != gaze)
            {
                if (gaze.X < dimX && gaze.X > dimX - clampHorsMargin)
                    clamped.X = dimX + 1;

                if(gaze.X > dimX + dimWidth && gaze.X < (dimX + dimWidth + clampHorsMargin))
                    clamped.X = dimX + dimWidth - 1;

                if (gaze.Y < dimY && gaze.Y > dimY - clampVertMargin)
                    clamped.Y = dimY + 1;

                if (gaze.Y > dimY + dimHeight && gaze.Y < (dimY + dimHeight + clampVertMargin))
                    clamped.Y = dimY + dimHeight - 1;
            }

            return clamped;
        }
示例#9
0
 /// <summary>
 /// Converts a 2d screen point in pixels to normalized relative values based on parameter dimensions.
 /// </summary>
 /// <param name="point">gaze point to base calculation upon</param>
 /// <param name="dimWidthPix">dimension width in pixels to base calculation upon</param>
 /// <param name="dimHeightPix">dimension height in pixels to base calculation upon</param>
 /// <returns>2D point in relative values</returns>
 public static Point2D GetScreenSpaceToRelative(Point2D point, int dimWidthPix, int dimHeightPix)
 {
     return new Point2D(
             point.X / GazeManager.Instance.ScreenResolutionWidth,
             point.Y / GazeManager.Instance.ScreenResolutionHeight
             );
 }
示例#10
0
 /// <summary>
 /// Clamps a gaze points within the limits of the parameter rect.
 /// </summary>
 /// <param name="gaze">gaze data frame to base calculation upon</param>
 /// <param name="dimX">x coordinate of topleft rect anchor</param>
 /// <param name="dimY">y coordinate of topleft rect anchor</param>
 /// <param name="dimWidth">dimension width to base calculation upon</param>
 /// <param name="dimHeight">dimension height to base calculation upon</param>
 /// <returns>clamped gaze point</returns>
 public static Point2D ClampGazeToRect(Point2D gaze, int dimX, int dimY, int dimWidth, int dimHeight)
 {
     return ClampGazeToRect(gaze, dimX, dimY, dimWidth, dimHeight, 0, 0);
 }
示例#11
0
 /// <summary>
 /// Converts a 2d point in relative values to a coordinate within parameter dimensions.
 /// <para/>
 /// Use to map relative values [0f..1f] to screen coordinates.
 /// </summary>
 /// <param name="point">gaze point to base calculation upon</param>
 /// <param name="dimWidthPix">dimension width in pixels to base calculation upon</param>
 /// <param name="dimHeightPix">dimension height in pixels to base calculation upon</param>
 /// <returns>2D point in screen space</returns>
 public static Point2D GetRelativeToScreenSpace(Point2D point, int dimWidthPix, int dimHeightPix)
 {
     return new Point2D(
         point.X * dimWidthPix,
         point.Y * dimHeightPix
         );
 }
示例#12
0
        /// <summary>
        /// Maps a 2d pixel point into normalized space [x: -1:1 , y: -1:1]
        /// </summary>
        /// <param name="point">point in pixels to normalize</param>
        /// <param name="screenWidth">the width value to base normalization upon</param>
        /// <param name="screenHeight">the height value to base normalization upon</param>
        /// <returns>normalized 2d point</returns> 
        public static Point2D GetNormalizedMapping(Point2D point, int screenWidth, int screenHeight)
        {
            Point2D normMap = GetNormalizedCoords(point, screenWidth, screenHeight);

            //scale up and shift
            normMap.X *= 2f;
            normMap.X -= 1f;
            normMap.Y *= 2f;
            normMap.Y -= 1f;

            return normMap;
        }
示例#13
0
 /// <summary>
 /// Normalizes a pixel point based on screen dims
 /// </summary>
 /// <param name="point">point in pixels to normalize</param>
 /// <param name="screenWidth">the width value to base normalization upon</param>
 /// <param name="screenHeight">the height value to base normalization upon</param>
 /// <returns>normalized 2d point</returns> 
 public static Point2D GetNormalizedCoords(Point2D point, int screenWidth, int screenHeight)
 {
     return new Point2D(point.X /= screenWidth, point.Y /= screenHeight);
 }
示例#14
0
        /// <summary>
        /// Find average pupil center of two eyes.
        /// </summary>
        /// <param name="leftEye"></param>
        /// <param name="rightEye"></param>
        /// <returns>the average center point in normalized values</returns>
        public static Point2D GetEyesCenterNormalized(Eye leftEye, Eye rightEye)
        {
            Point2D eyeCenter = Point2D.Zero;

            if (null != leftEye && null != rightEye)
            {
                eyeCenter = new Point2D(
                        (leftEye.PupilCenterCoordinates.X + rightEye.PupilCenterCoordinates.X) / 2,
                        (leftEye.PupilCenterCoordinates.Y + rightEye.PupilCenterCoordinates.Y) / 2
                        );
            }
            else if (null != leftEye)
            {
                eyeCenter = leftEye.PupilCenterCoordinates;
            }
            else if (null != rightEye)
            {
                eyeCenter = rightEye.PupilCenterCoordinates;
            }

            return eyeCenter;
        }
示例#15
0
 /// <summary>
 /// Calculates distance between two points.
 /// </summary>
 public static double GetDistancePoint2D(Point2D a, Point2D b)
 {
     return Math.Sqrt(Math.Pow(a.X - b.X, 2) + Math.Pow(a.Y - b.Y, 2));
 }