private void GetTrackingPoints(FastBitmap img, EyeData leftEye, EyeData rightEye) { const int YDownShift = 30; const int XExpand = 5; const float eyebrowMult = 0.6f; int eyebrowWidth = (int)Math.Abs((leftEye.loc.X - rightEye.loc.X) * eyebrowMult); Rectangle searchArea = new Rectangle(); FastBitmap smoothed = img.GaussianSmooth(5); FastBitmap sobel = smoothed.SobelGradient(); smoothed.Dispose(); searchArea.Y = Math.Max(leftEye.loc.Y, rightEye.loc.Y) + YDownShift; searchArea.X = leftEye.loc.X - XExpand; searchArea.Width = rightEye.loc.X - leftEye.loc.X + (2 * XExpand); searchArea.Height = (int)((rightEye.loc.X - leftEye.loc.X) * 0.6f); float[,] trackingPointScores = new float[searchArea.Width, searchArea.Height]; for (int x = searchArea.Left; x < searchArea.Right; ++x) { for (int y = searchArea.Top; y < searchArea.Bottom; ++y) { float score = 0; for (int i = 0; i < TrackingPointWidth; ++i) { for (int j = 0; j < TrackingPointWidth; ++j) { score += sobel.GetIntensity(x + i, y + j); } } trackingPointScores[x - searchArea.Left, y - searchArea.Top] = score; } } mouseTrackingPoint = GetBestTrackingPointWithinColumn(trackingPointScores, searchArea, (leftEye.loc.X + rightEye.loc.X) / 2); leftEyeTrackingPoint = GetBestTrackingForEye(sobel, leftEye, eyebrowWidth); rightEyeTrackingPoint = GetBestTrackingForEye(sobel, rightEye, eyebrowWidth); sobel.Dispose(); }