changes: 1) fixes problems in the original EyeTracking benchmark 2) fix a bug in...
[IRC.git] / Robust / src / Benchmarks / SSJava / EyeTrackingInfer / EyeDetector.java
index 11443ab58bc6de16bfe67e642883a3f2c313ba65..6e21f392618313b70907bd5b3c2a10e5c6a68363 100644 (file)
@@ -35,12 +35,15 @@ class EyeDetector {
   
   double percent;
 
-  public EyeDetector(Image image, Rectangle2D faceRect) {
+  // public EyeDetector(Image image, Rectangle2D faceRect) {
+  public EyeDetector(Image image, double fx, double fy, double fwidth, double fheight) {
 
-    percent = 0.15 * faceRect.getWidth();
-    Rectangle2D adjustedFaceRect =
-        new Rectangle2D(faceRect.getX() + percent, faceRect.getY() + percent, faceRect.getWidth()
-            - percent, faceRect.getHeight() - 2 * percent);
+    percent = 0.15 * fwidth;
+    Rectangle2D adjustedFaceRect = new Rectangle2D(fx + percent, fy + percent, fwidth - percent, fheight - 2 * percent);
+    // percent = 0.15 * faceRect.getWidth();
+    // Rectangle2D adjustedFaceRect =
+    // new Rectangle2D(faceRect.getX() + percent, faceRect.getY() + percent, faceRect.getWidth()
+    // - percent, faceRect.getHeight() - 2 * percent);
 
     width = (int) adjustedFaceRect.getWidth() / 2;
     height = (int) adjustedFaceRect.getHeight() / 2;
@@ -63,10 +66,8 @@ class EyeDetector {
      float brightness = 255f;
     for ( int y = 0; y < height; ++y) {
       for ( int x = 0; x < width; ++x) {
-         final int position = y * width + x;
-         final int[] color =
-            new int[] { (pixelBuffer[position] & 0xFF0000) >> 16,
-                (pixelBuffer[position] & 0x00FF00) >> 8, pixelBuffer[position] & 0x0000FF };
+         int position = y * width + x;
+         int[] color =  new int[] { (pixelBuffer[position] & 0xFF0000) >> 16,(pixelBuffer[position] & 0x00FF00) >> 8, pixelBuffer[position] & 0x0000FF };
         // System.out.println("("+x+","+y+")="+color[0]+" "+color[1]+" "+color[2]);
          final float acBrightness = getBrightness(color);