changes: 1) fixes problems in the original EyeTracking benchmark 2) fix a bug in...
[IRC.git] / Robust / src / Benchmarks / SSJava / EyeTracking / LEA.java
index 3aad7e86138a027b995ff44f1f0e8b4719504b58..3197ac346b65d411f101ce459bbe4ba80b838754 100644 (file)
  * 
  * @author Florian Frankenberger
  */
+@LATTICE("LAST<DEV,DEV<POS,POS<IMPL")
+@METHODDEFAULT("OUT<THIS,THIS<IN,THISLOC=THIS,RETURNLOC=OUT")
 public class LEA {
 
-  private boolean shutdown = false;
+  @LOC("IMPL")
   private LEAImplementation implementation;
-
-  private FaceAndEyePosition lastPositions = new FaceAndEyePosition(null, null);
+  @LOC("LAST")
+  private FaceAndEyePosition lastPositions = new FaceAndEyePosition(-1,-1,-1,-1, null);
+  @LOC("DEV")
   private DeviationScanner deviationScanner = new DeviationScanner();
-  private int counter = 0;
-
-  // private ImageProcessor imageProcessor;
-  //
-  // private class ImageProcessor extends TimedThread {
-  //
-  // private FaceAndEyePosition lastPositions = new FaceAndEyePosition(null,
-  // null);
-  // private DeviationScanner deviationScanner = new DeviationScanner();
-  // private int counter = 0;
-  //
-  // private int fps;
-  //
-  // public ImageProcessor(int fps) {
-  // super(fps);
-  // this.fps = fps;
-  // }
-  //
-  // @Override
-  // public void doRun() {
-  //
-  // BufferedImage image = captureDevice.getImage();
-  // if (image == null)
-  // return;
-  //
-  // try {
-  // FaceAndEyePosition positions = implementation.getEyePosition(image);
-  //
-  // if (((lastPositions.getFacePosition() == null &&
-  // positions.getFacePosition() != null) || (lastPositions
-  // .getFacePosition() != null && positions.getFacePosition() == null)) ||
-  // counter++ > fps) {
-  //
-  // if ((lastPositions.getFacePosition() == null && positions.getFacePosition()
-  // != null)
-  // || (lastPositions.getFacePosition() != null && positions.getFacePosition()
-  // == null)) {
-  // if (positions.getFacePosition() != null) {
-  // notifyEyeMovementListenerFaceDetected();
-  // } else {
-  // notifyEyeMovementListenerFaceLost();
-  // }
-  // }
-  // counter = 0;
-  // if (statusWindow != null)
-  // statusWindow.getFaceInfoPanel().setFace(image,
-  // positions.getFacePosition());
-  // }
-  //
-  // if (positions.getEyePosition() != null) {
-  // if (statusWindow != null) {
-  // statusWindow.getEyeInfoPanel().setEyePosition(image,
-  // positions.getFacePosition(),
-  // positions.getEyePosition());
-  // }
-  // deviationScanner.addEyePosition(positions.getEyePosition());
-  // Deviation deviation =
-  // deviationScanner.scanForDeviation(positions.getFacePosition());//
-  // positions.getEyePosition().getDeviation(lastPositions.getEyePosition());
-  //
-  // if (deviation != Deviation.NONE) {
-  // notifyEyeMovementListenerEyeMoved(deviation);
-  // }
-  //
-  // } else {
-  // if (statusWindow != null)
-  // statusWindow.getEyeInfoPanel().setDeviation(null);
-  // }
-  //
-  // lastPositions = positions;
-  // } catch (Exception e) {
-  // e.printStackTrace();
-  // try {
-  // close();
-  // } catch (Exception e2) {
-  // }
-  // }
-  // }
-  //
-  // public synchronized void clearDeviationScanner() {
-  // this.deviationScanner.clear();
-  // }
-  //
-  // }
 
   public LEA() {
     // this.imageProcessor = new
@@ -159,8 +78,8 @@ public class LEA {
   }
 
   /**
-   * To test LEA with the first capture device from the
-   * <code>Java Media Framework</code> just start from here.
+   * @METHOD To test LEA with the first capture device from the
+   *         <code>Java Media Framework</code> just start from here.
    * 
    * @param args
    * @throws Exception
@@ -170,16 +89,13 @@ public class LEA {
     lea.doRun();
   }
 
+  @LATTICE("THIS<IMG,IMG<C,C*,THISLOC=THIS")
   public void doRun() {
 
-    int maxCount = 37;
-    int i = 0;
-
-    ImageReader reader = new ImageReader();
+    @LOC("C") int i = 0;
 
-    while (i < maxCount) {
-      Image image = reader.readImage("data/b" + i + ".bmp");
-      i++;
+    SSJAVA: while (true) {
+      @LOC("IMG") Image image =  ImageReader.getImage();
       if (image == null) {
         break;
       }
@@ -189,31 +105,20 @@ public class LEA {
     System.out.println("Done.");
 
   }
-
-  private void processImage(Image image) {
-
-    FaceAndEyePosition positions = implementation.getEyePosition(image);
-
-    if (positions.getEyePosition() != null) {
-      deviationScanner.addEyePosition(positions.getEyePosition());
-      Deviation deviation = deviationScanner.scanForDeviation(positions.getFacePosition());// positions.getEyePosition().getDeviation(lastPositions.getEyePosition());
-      if (deviation != DeviationScanner.NONE) {
-        System.out.println("deviation=" + deviation);
-        // notifyEyeMovementListenerEyeMoved(deviation);
-      }
+  
+
+  private void processImage(@LOC("IN") Image image) {
+    @LOC("THIS,LEA.POS") FaceAndEyePosition positions = implementation.getEyePosition(image);
+    // if (positions.getEyePosition() != null) {
+    deviationScanner.addEyePosition(positions.getEyePosition());
+    @LOC("THIS,LEA.DEV,DeviationScanner.DEV") int deviation =
+        deviationScanner.scanForDeviation(positions.getFacePosition());// positions.getEyePosition().getDeviation(lastPositions.getEyePosition());
+    if (deviation != DeviationScanner.NONE) {
+      System.out.println("deviation=" + deviationScanner.toStringDeviation(deviation));
+      // notifyEyeMovementListenerEyeMoved(deviation);
     }
-    // else {
-    // if (statusWindow != null)
-    // statusWindow.getEyeInfoPanel().setDeviation(null);
     // }
     lastPositions = positions;
-    // } catch (Exception e) {
-    // e.printStackTrace();
-    // try {
-    // close();
-    // } catch (Exception e2) {
-    // }
-    // }
   }
 
 }