public double GetVariancePupilArea(EyeEnum eye) { var list = new List <double>(); foreach (TrackData td in db) { if (eye == EyeEnum.Left && td.PupilDataLeft != null && td.PupilDataLeft.Blob != null) { list.Add(td.PupilDataLeft.Blob.Area); } if (eye == EyeEnum.Right && td.PupilDataRight != null && td.PupilDataRight.Blob != null) { list.Add(td.PupilDataRight.Blob.Area); } } if (list.Count != 0) { return(Operations.Variance(list.ToArray())); } else { return(9999); } }
private static void ApplyEstimatedEyeROI(EyeEnum eye, TrackData trackData, Size imageSize) { // If the feature detection was used the trackdata.LeftROI/RightROI will already be set (roi != 0) // If detector hasen't been used (eg. roi=0) then values from previous frame should be used // Update: We set the values on the trackdata object instead of returning a rectangle. var roi = new Rectangle(new Point(0, 0), new Size(imageSize.Width, imageSize.Height)); switch (eye) { case EyeEnum.Left: if (trackData.LeftROI.Width == 0) { trackData.LeftROI = TrackDB.Instance.GetLastEyeROI(EyeEnum.Left, imageSize); } break; case EyeEnum.Right: if (trackData.RightROI.Width == 0) { trackData.RightROI = TrackDB.Instance.GetLastEyeROI(EyeEnum.Right, imageSize); } break; } Performance.Now.Stamp("ROI Estimated"); }
public double GetMeanPupilFullness(EyeEnum eye) { var list = new List <double>(); foreach (TrackData td in db) { if (eye == EyeEnum.Left && td.PupilDataLeft.Blob != null) { list.Add(td.PupilDataLeft.Blob.Fullness); } if (eye == EyeEnum.Right && td.PupilDataRight.Blob != null) { list.Add(td.PupilDataRight.Blob.Fullness); } } if (list.Count != 0) { return(Operations.Mean(list.ToArray())); } else { return(9999); } }
public override GTPoint GetGazeCoordinates(TrackData trackData, EyeEnum eye) { var row = new Matrix <double>(6, 1); var screenCoordinates = new Matrix <double>(2, 1); var gazedPoint = new GTPoint(); try { double X = 0; double Y = 0; switch (eye) { case EyeEnum.Left: X = trackData.PupilDataLeft.Center.X - trackData.GlintDataLeft.Glints.AverageCenter.X; Y = trackData.PupilDataLeft.Center.Y - trackData.GlintDataLeft.Glints.AverageCenter.Y; break; default: X = trackData.PupilDataRight.Center.X - trackData.GlintDataRight.Glints.AverageCenter.X; Y = trackData.PupilDataRight.Center.Y - trackData.GlintDataRight.Glints.AverageCenter.Y; break; } row[0, 0] = 1; row[1, 0] = X; row[2, 0] = Y; row[3, 0] = X * Y; row[4, 0] = X * X; row[5, 0] = Y * Y; if (eye == EyeEnum.Left) { if (CalibrationDataLeft != null && CalibrationDataLeft.CoeffsX != null) { gazedPoint.X = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataLeft.CoeffsX.Ptr); gazedPoint.Y = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataLeft.CoeffsY.Ptr); } } else { if (CalibrationDataRight != null && CalibrationDataRight.CoeffsX != null) { gazedPoint.X = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataRight.CoeffsX.Ptr); gazedPoint.Y = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataRight.CoeffsY.Ptr); } } } catch (Exception ex) { Console.Out.WriteLine("Calibration.cs, exception in GetGazeCoordinates(), message: " + ex.Message); } return(gazedPoint); }
public void SaveROIImage(long counter, Image <Gray, byte> inputEye, EyeEnum eyeEnum) { try { if (eyeEnum == EyeEnum.Left) { inputEye.Bitmap.Save(dataPath + "\\" + InstanceTargetNumber + "-" + counter + "-L.png"); } else { inputEye.Bitmap.Save(dataPath + "\\" + InstanceTargetNumber + "-" + counter + "-R.png"); } } catch (Exception) { } }
public double CalculatePupilHitRatio(EyeEnum eye, int numberOfSample) { int misses = 0; foreach (TrackData t in db) { if (eye == EyeEnum.Left && t.PupilDataLeft.Center.X == 0) { misses++; } else if (eye == EyeEnum.Right && t.PupilDataRight.Center.X == 0) { misses++; } } return((double)misses / db.Count * 100); }
public double GetVariancePupilFullness(EyeEnum eye) { var list = new List<double>(); foreach (TrackData td in db) { if (eye == EyeEnum.Left && td.PupilDataLeft.Blob != null) list.Add(td.PupilDataLeft.Blob.Fullness); if (eye == EyeEnum.Right && td.PupilDataRight.Blob != null) list.Add(td.PupilDataRight.Blob.Fullness); } if (list.Count != 0) return Operations.Variance(list.ToArray()); else return 9999; }
public double CalculateGlintHitRatio(EyeEnum eye) { int misses = 0; foreach (TrackData t in db) { if (eye == EyeEnum.Left && t.GlintDataLeft.Glints.Count == 0) { misses++; } else if (eye == EyeEnum.Right && t.GlintDataRight.Glints.Count == 0) { misses++; } } return((double)misses / db.Count * 100); }
public Rectangle GetLastEyeROI(EyeEnum eye, Size imgSize) { TrackData[] tds = db.ToArray(); for (int i = tds.Length - 1; i >= 0; i--) { if (eye == EyeEnum.Left && tds[i].LeftROI.Width != 0) { return(tds[i].LeftROI); } if (eye == EyeEnum.Right && tds[i].RightROI.Width != 0) { return(tds[i].RightROI); } } return(new Rectangle(0, 0, imgSize.Width, imgSize.Height)); }
private static PupilData ConvertPupilToAbsolute(EyeEnum eye, PupilData pupilData, TrackData trackData) { var eyeROI = new Rectangle(); if (eye == EyeEnum.Left) { eyeROI = trackData.LeftROI; } else { eyeROI = trackData.RightROI; } pupilData.Center.X += eyeROI.X; pupilData.Center.Y += eyeROI.Y; pupilData.Blob.CenterOfGravity = new GTPoint(pupilData.Blob.CenterOfGravity.X + eyeROI.X, pupilData.Blob.CenterOfGravity.Y + eyeROI.Y); return(pupilData); }
public PointF GetSlopePupilFullness(EyeEnum eye, int numSamples) { TrackData[] tds = db.ToArray(); var points = new PointF[numSamples]; var direction = new PointF(); var pointOnLine = new PointF(); for (int i = tds.Length - 1; i >= tds.Length - numSamples; i--) { if (eye == EyeEnum.Left && tds[i].PupilDataLeft.Blob != null) { points[tds.Length - i - 1] = new PointF(i, (float)tds[i].PupilDataLeft.Blob.Fullness); } } PointCollection.Line2DFitting(points, DIST_TYPE.CV_DIST_L2, out direction, out pointOnLine); return(direction); }
private static void CenterROIOnPupil(TrackData trackData, EyeEnum eye, Size imageSize) { var roi = new Rectangle(); switch (eye) { case EyeEnum.Left: roi = trackData.LeftROI; // for size if (roi.Width != 0) { roi.X = (int)trackData.PupilDataLeft.Center.X - roi.Width / 2; // center it roi.Y = (int)trackData.PupilDataLeft.Center.Y - roi.Height / 2; if (roi.X > 0 && roi.Right < imageSize.Width && roi.Y > 0 && roi.Bottom < imageSize.Height) { trackData.LeftROI = roi; // ok, within image } } break; case EyeEnum.Right: roi = trackData.RightROI; if (roi.Width != 0) { roi.X = (int)trackData.PupilDataRight.Center.X - roi.Width / 2; roi.Y = (int)trackData.PupilDataRight.Center.Y - roi.Height / 2; if (roi.X > 0 && roi.Right < imageSize.Width && roi.Y > 0 && roi.Bottom < imageSize.Height) { trackData.RightROI = roi; } } break; } }
public GTPoint GetGazeCoordinates(EyeEnum eye) { var row = new Matrix <double>(6, 1); var screenCoordinates = new Matrix <double>(2, 1); var gazedPoint = new GTPoint(); double x, y; if (eye == EyeEnum.Left) { x = PupilCenterLeft.X; y = PupilCenterLeft.Y; } else { x = PupilCenterRight.X; y = PupilCenterRight.Y; } row[0, 0] = 1; row[1, 0] = x; row[2, 0] = y; row[3, 0] = x * y; row[4, 0] = x * x; row[5, 0] = y * y; if (eye == EyeEnum.Left) { gazedPoint.X = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataLeft.CoeffsX.Ptr); gazedPoint.Y = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataLeft.CoeffsY.Ptr); } else { gazedPoint.X = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataRight.CoeffsX.Ptr); gazedPoint.Y = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataRight.CoeffsY.Ptr); } return(gazedPoint); }
public GTPoint GetGazeCoordinates(EyeEnum eye, GTPoint pupilCenter, GlintConfiguration glintConfig) { var row = new Matrix <double>(6, 1); var screenCoordinates = new Matrix <double>(2, 1); var gazedPoint = new GTPoint(); double X, Y; try { X = pupilCenter.X - glintConfig.AverageCenter.X; Y = pupilCenter.Y - glintConfig.AverageCenter.Y; row[0, 0] = 1; row[1, 0] = X; row[2, 0] = Y; row[3, 0] = X * Y; row[4, 0] = X * X; row[5, 0] = Y * Y; if (eye == EyeEnum.Left) { gazedPoint.X = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataLeft.CoeffsX.Ptr); gazedPoint.Y = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataLeft.CoeffsY.Ptr); } else { gazedPoint.X = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataRight.CoeffsX.Ptr); gazedPoint.Y = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataRight.CoeffsY.Ptr); } } catch (Exception ex) { Console.Out.WriteLine("Calibration.cs, exception in GetGazeCoordinates(), message: " + ex.Message); } return(gazedPoint); }
private static void ApplyEstimatedEyeROI(EyeEnum eye, TrackData trackData, Size imageSize) { // If the feature detection was used the trackdata.LeftROI/RightROI will already be set (roi != 0) // If detector hasen't been used (eg. roi=0) then values from previous frame should be used // Update: We set the values on the trackdata object instead of returning a rectangle. var roi = new Rectangle(new Point(0, 0), new Size(imageSize.Width, imageSize.Height)); switch (eye) { case EyeEnum.Left: if (trackData.LeftROI.Width == 0) trackData.LeftROI = TrackDB.Instance.GetLastEyeROI(EyeEnum.Left, imageSize); break; case EyeEnum.Right: if (trackData.RightROI.Width == 0) trackData.RightROI = TrackDB.Instance.GetLastEyeROI(EyeEnum.Right, imageSize); break; } Performance.Now.Stamp("ROI Estimated"); }
public double CalculateGlintHitRatio(EyeEnum eye) { int misses = 0; foreach (TrackData t in db) { if (eye == EyeEnum.Left && t.GlintDataLeft.Glints.Count == 0) misses++; else if (eye == EyeEnum.Right && t.GlintDataRight.Glints.Count == 0) misses++; } return (double) misses/db.Count*100; }
public GTPoint GetGazeCoordinates(EyeEnum eye, GTPoint pupilCenter, GlintConfiguration glintConfig) { var row = new Matrix<double>(6, 1); var screenCoordinates = new Matrix<double>(2, 1); var gazedPoint = new GTPoint(); double X, Y; try { X = pupilCenter.X - glintConfig.AverageCenter.X; Y = pupilCenter.Y - glintConfig.AverageCenter.Y; row[0, 0] = 1; row[1, 0] = X; row[2, 0] = Y; row[3, 0] = X*Y; row[4, 0] = X*X; row[5, 0] = Y*Y; if (eye == EyeEnum.Left) { gazedPoint.X = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataLeft.CoeffsX.Ptr); gazedPoint.Y = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataLeft.CoeffsY.Ptr); } else { gazedPoint.X = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataRight.CoeffsX.Ptr); gazedPoint.Y = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataRight.CoeffsY.Ptr); } } catch (Exception ex) { Console.Out.WriteLine("Calibration.cs, exception in GetGazeCoordinates(), message: " + ex.Message); } return gazedPoint; }
public abstract GTPoint GetGazeCoordinates(TrackData trackData, EyeEnum eye);
public PupilDetection(EyeEnum eye) { Init(); pupilData.Eye = eye; this.eye = eye; }
public Rectangle GetLastEyeROI(EyeEnum eye, Size imgSize) { TrackData[] tds = db.ToArray(); for (int i = tds.Length - 1; i >= 0; i--) { switch (eye) { case EyeEnum.Left: //if (tds[i].LeftROI.Width != 0 && // Operations.IsWithinBounds(tds[i].LeftROI, // new Rectangle(0, 0, imgSize.Width, imgSize.Height))) // Eye roi not set if (tds[i].LeftROI.X == 0 || tds[i].LeftROI.Y == 0) { continue; } // Last sample roi not set if (tds[i].CameraROI.Y == 0 || tds[i].CameraROI.X == 0) { if (Operations.IsWithinBounds(tds[i].LeftROI, new Rectangle(0, 0, imgSize.Width, imgSize.Height))) { return(tds[i].LeftROI); } } // Camera roi changed if (i > 1) // we have samples { if (tds[i - 1].CameraROI.Y != 0 && tds[i - 1].CameraROI.X != 0) // prior sample has camera roi { if (tds[i].CameraROI.Y != tds[i - 1].CameraROI.Y || tds[i].CameraROI.X != tds[i - 1].CameraROI.X) // they differ { int x = 0; int y = 0; // Position between last and n-1 differs, roi has been recenterd if (tds[i - 1].CameraROI.Y != 0) { x = tds[i].LeftROI.X; y = imgSize.Height / 2 - tds[i].LeftROI.Height / 2; } if (tds[i - 1].CameraROI.X != 0) { x = tds[i].LeftROI.X; x -= tds[i].LeftROI.X - tds[i - 1].LeftROI.X; } if (x != 0 || y != 0) { return(new Rectangle(x, y, tds[i].LeftROI.Width, tds[i].LeftROI.Height)); } } else if (Operations.IsWithinBounds(tds[i].LeftROI, new Rectangle(0, 0, imgSize.Width, imgSize.Height))) { return(tds[i].LeftROI); } } } //} break; case EyeEnum.Right: //if (tds[i].RightROI.Width != 0 && Operations.IsWithinBounds(tds[i].RightROI, new Rectangle(0, 0, imgSize.Width, imgSize.Height))) //{ // Eye roi not set if (tds[i].RightROI.X == 0 || tds[i].RightROI.Y == 0) { continue; } // Last sample roi not set if (tds[i].CameraROI.Y == 0 || tds[i].CameraROI.X == 0) { if (Operations.IsWithinBounds(tds[i].RightROI, new Rectangle(0, 0, imgSize.Width, imgSize.Height))) { return(tds[i].RightROI); } } // Camera roi changed if (i > 1) // we have samples { if (tds[i - 1].CameraROI.Y != 0 && tds[i - 1].CameraROI.X != 0) // prior sample has camera roi { if (tds[i].CameraROI.Y != tds[i - 1].CameraROI.Y || tds[i].CameraROI.X != tds[i - 1].CameraROI.X) // they differ { int x = 0; int y = 0; // Position between last and n-1 differs, roi has been recenterd if (tds[i - 1].CameraROI.Y != 0) { x = tds[i].RightROI.X; y = imgSize.Height / 2 - tds[i].RightROI.Height / 2; } if (tds[i - 1].CameraROI.X != 0) { x = tds[i].RightROI.X; x -= tds[i].RightROI.X - tds[i - 1].RightROI.X; } if (x != 0 || y != 0) { return(new Rectangle(x, y, tds[i].RightROI.Width, tds[i].RightROI.Height)); } } else if (Operations.IsWithinBounds(tds[i].RightROI, new Rectangle(0, 0, imgSize.Width, imgSize.Height))) { return(tds[i].RightROI); } } } //} //return new Rectangle(0, 0, imgSize.Width, imgSize.Height); break; } } //if (eye == EyeEnum.Left && tds[i].LeftROI.Width != 0 && // tds[i].LeftROI.Width <= imgSize.Width && // tds[i].LeftROI.Height <= imgSize.Height) // return tds[i].LeftROI; //if (eye == EyeEnum.Right && tds[i].RightROI.Width != 0 && // tds[i].RightROI.Width <= imgSize.Width && // tds[i].RightROI.Height <= imgSize.Height) // return tds[i].RightROI; return(new Rectangle(0, 0, imgSize.Width, imgSize.Height)); }
public GTPoint GetGazeCoordinates(EyeEnum eye) { var row = new Matrix<double>(6, 1); var screenCoordinates = new Matrix<double>(2, 1); var gazedPoint = new GTPoint(); double x, y; if (eye == EyeEnum.Left) { x = PupilCenterLeft.X; y = PupilCenterLeft.Y; } else { x = PupilCenterRight.X; y = PupilCenterRight.Y; } row[0, 0] = 1; row[1, 0] = x; row[2, 0] = y; row[3, 0] = x*y; row[4, 0] = x*x; row[5, 0] = y*y; if (eye == EyeEnum.Left) { gazedPoint.X = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataLeft.CoeffsX.Ptr); gazedPoint.Y = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataLeft.CoeffsY.Ptr); } else { gazedPoint.X = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataRight.CoeffsX.Ptr); gazedPoint.Y = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataRight.CoeffsY.Ptr); } return gazedPoint; }
public override GTPoint GetGazeCoordinates(TrackData trackData, EyeEnum eye) { var row = new Matrix<double>(6, 1); var screenCoordinates = new Matrix<double>(2, 1); var gazedPoint = new GTPoint(); try { double X = 0; double Y = 0; switch (eye) { case EyeEnum.Left: X = trackData.PupilDataLeft.Center.X - trackData.GlintDataLeft.Glints.AverageCenter.X; Y = trackData.PupilDataLeft.Center.Y - trackData.GlintDataLeft.Glints.AverageCenter.Y; break; default: X = trackData.PupilDataRight.Center.X - trackData.GlintDataRight.Glints.AverageCenter.X; Y = trackData.PupilDataRight.Center.Y - trackData.GlintDataRight.Glints.AverageCenter.Y; break; } row[0, 0] = 1; row[1, 0] = X; row[2, 0] = Y; row[3, 0] = X*Y; row[4, 0] = X*X; row[5, 0] = Y*Y; if (eye == EyeEnum.Left) { if (CalibrationDataLeft != null && CalibrationDataLeft.CoeffsX != null) { gazedPoint.X = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataLeft.CoeffsX.Ptr); gazedPoint.Y = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataLeft.CoeffsY.Ptr); } } else { if (CalibrationDataRight != null && CalibrationDataRight.CoeffsX != null) { gazedPoint.X = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataRight.CoeffsX.Ptr); gazedPoint.Y = CvInvoke.cvDotProduct(row.Ptr, CalibrationDataRight.CoeffsY.Ptr); } } } catch (Exception ex) { Console.Out.WriteLine("Calibration.cs, exception in GetGazeCoordinates(), message: " + ex.Message); } return gazedPoint; }
public double CalculatePupilHitRatio(EyeEnum eye, int numberOfSample) { int misses = 0; foreach (TrackData t in db) { if (eye == EyeEnum.Left && t.PupilDataLeft.Center.X == 0) misses++; else if (eye == EyeEnum.Right && t.PupilDataRight.Center.X == 0) misses++; } return (double) misses/db.Count*100; }
public void SaveROIImage(long counter, Image<Gray, byte> inputEye, EyeEnum eyeEnum) { try { if (eyeEnum == EyeEnum.Left) inputEye.Bitmap.Save(dataPath + "\\" + InstanceTargetNumber + "-" + counter + "-L.png"); else inputEye.Bitmap.Save(dataPath + "\\" + InstanceTargetNumber + "-" + counter + "-R.png"); } catch (Exception) { } }
private static void CenterROIOnPupil(TrackData trackData, EyeEnum eye, Size imageSize) { var roi = new Rectangle(); switch (eye) { case EyeEnum.Left: roi = trackData.LeftROI; // for size if (roi.Width != 0) { roi.X = (int) trackData.PupilDataLeft.Center.X - roi.Width/2; // center it roi.Y = (int) trackData.PupilDataLeft.Center.Y - roi.Height/2; if (roi.X > 0 && roi.Right < imageSize.Width && roi.Y > 0 && roi.Bottom < imageSize.Height) trackData.LeftROI = roi; // ok, within image } break; case EyeEnum.Right: roi = trackData.RightROI; if (roi.Width != 0) { roi.X = (int) trackData.PupilDataRight.Center.X - roi.Width/2; roi.Y = (int) trackData.PupilDataRight.Center.Y - roi.Height/2; if (roi.X > 0 && roi.Right < imageSize.Width && roi.Y > 0 && roi.Bottom < imageSize.Height) trackData.RightROI = roi; } break; } }
public abstract GTPoint GetGazeCoordinates(TrackData trackData, EyeEnum eye);
private static PupilData ConvertPupilToAbsolute(EyeEnum eye, PupilData pupilData, TrackData trackData) { var eyeROI = new Rectangle(); if (eye == EyeEnum.Left) eyeROI = trackData.LeftROI; else eyeROI = trackData.RightROI; pupilData.Center.X += eyeROI.X; pupilData.Center.Y += eyeROI.Y; pupilData.Blob.CenterOfGravity = new GTPoint(pupilData.Blob.CenterOfGravity.X + eyeROI.X, pupilData.Blob.CenterOfGravity.Y + eyeROI.Y); return pupilData; }
public Rectangle GetLastEyeROI(EyeEnum eye, Size imgSize) { TrackData[] tds = db.ToArray(); for (int i = tds.Length - 1; i >= 0; i--) { switch (eye) { case EyeEnum.Left: //if (tds[i].LeftROI.Width != 0 && // Operations.IsWithinBounds(tds[i].LeftROI, // new Rectangle(0, 0, imgSize.Width, imgSize.Height))) // Eye roi not set if (tds[i].LeftROI.X == 0 || tds[i].LeftROI.Y == 0) continue; // Last sample roi not set if (tds[i].CameraROI.Y == 0 || tds[i].CameraROI.X == 0) if (Operations.IsWithinBounds(tds[i].LeftROI, new Rectangle(0, 0, imgSize.Width, imgSize.Height))) return tds[i].LeftROI; // Camera roi changed if (i > 1) // we have samples if(tds[i - 1].CameraROI.Y != 0 && tds[i - 1].CameraROI.X != 0) // prior sample has camera roi if(tds[i].CameraROI.Y != tds[i - 1].CameraROI.Y || tds[i].CameraROI.X != tds[i - 1].CameraROI.X) // they differ { int x = 0; int y = 0; // Position between last and n-1 differs, roi has been recenterd if (tds[i - 1].CameraROI.Y != 0) { x = tds[i].LeftROI.X; y = imgSize.Height / 2 - tds[i].LeftROI.Height / 2; } if (tds[i - 1].CameraROI.X != 0) { x = tds[i].LeftROI.X; x -= tds[i].LeftROI.X - tds[i - 1].LeftROI.X; } if (x != 0 || y != 0) return new Rectangle(x, y, tds[i].LeftROI.Width, tds[i].LeftROI.Height); } else if(Operations.IsWithinBounds(tds[i].LeftROI, new Rectangle(0, 0, imgSize.Width, imgSize.Height))) { return tds[i].LeftROI; } //} break; case EyeEnum.Right: //if (tds[i].RightROI.Width != 0 && Operations.IsWithinBounds(tds[i].RightROI, new Rectangle(0, 0, imgSize.Width, imgSize.Height))) //{ // Eye roi not set if (tds[i].RightROI.X == 0 || tds[i].RightROI.Y == 0) continue; // Last sample roi not set if (tds[i].CameraROI.Y == 0 || tds[i].CameraROI.X == 0) if (Operations.IsWithinBounds(tds[i].RightROI, new Rectangle(0, 0, imgSize.Width, imgSize.Height))) return tds[i].RightROI; // Camera roi changed if (i > 1) // we have samples if (tds[i - 1].CameraROI.Y != 0 && tds[i - 1].CameraROI.X != 0) // prior sample has camera roi if (tds[i].CameraROI.Y != tds[i - 1].CameraROI.Y || tds[i].CameraROI.X != tds[i - 1].CameraROI.X) // they differ { int x = 0; int y = 0; // Position between last and n-1 differs, roi has been recenterd if (tds[i - 1].CameraROI.Y != 0) { x = tds[i].RightROI.X; y = imgSize.Height/2 - tds[i].RightROI.Height/2; } if (tds[i - 1].CameraROI.X != 0) { x = tds[i].RightROI.X; x -= tds[i].RightROI.X - tds[i - 1].RightROI.X; } if(x != 0 || y != 0) return new Rectangle(x, y, tds[i].RightROI.Width, tds[i].RightROI.Height); } else if(Operations.IsWithinBounds(tds[i].RightROI, new Rectangle(0, 0, imgSize.Width, imgSize.Height))) { return tds[i].RightROI; } //} //return new Rectangle(0, 0, imgSize.Width, imgSize.Height); break; } } //if (eye == EyeEnum.Left && tds[i].LeftROI.Width != 0 && // tds[i].LeftROI.Width <= imgSize.Width && // tds[i].LeftROI.Height <= imgSize.Height) // return tds[i].LeftROI; //if (eye == EyeEnum.Right && tds[i].RightROI.Width != 0 && // tds[i].RightROI.Width <= imgSize.Width && // tds[i].RightROI.Height <= imgSize.Height) // return tds[i].RightROI; return new Rectangle(0, 0, imgSize.Width, imgSize.Height); }
public GlintDetection(EyeEnum eye) { this.eye = eye; glintData = new GlintData(); blobDetector = new BlobDetector(); }
public PointF GetSlopePupilFullness(EyeEnum eye, int numSamples) { TrackData[] tds = db.ToArray(); var points = new PointF[numSamples]; var direction = new PointF(); var pointOnLine = new PointF(); for (int i = tds.Length - 1; i >= tds.Length - numSamples; i--) { if (eye == EyeEnum.Left && tds[i].PupilDataLeft.Blob != null) { points[tds.Length - i - 1] = new PointF(i, (float) tds[i].PupilDataLeft.Blob.Fullness); } } PointCollection.Line2DFitting(points, DIST_TYPE.CV_DIST_L2, out direction, out pointOnLine); return direction; }
public GTPoint GetGazeCoordinates(TrackData trackData, EyeEnum eye) { return(calibMethod.GetGazeCoordinates(trackData, eye)); }
public GTPoint GetGazeCoordinates(TrackData trackData, EyeEnum eye) { return calibMethod.GetGazeCoordinates(trackData, eye); }
public GlintDetection(EyeEnum eye) { this.eye = eye; glintData = new GlintData(); blobDetector = new BlobDetector(); }
public PupilDetection(EyeEnum eye) { Init(); pupilData.Eye = eye; this.eye = eye; }