-import Benchmarks.oooJava.barneshut.FileInputStream;
-
/*
* Copyright 2009 (c) Florian Frankenberger (darkblue.de)
*
*
* @author Florian Frankenberger
*/
+@LATTICE("LAST<DEV,DEV<POS,POS<IMPL")
+@METHODDEFAULT("OUT<THIS,THIS<IN,THISLOC=THIS,RETURNLOC=OUT")
public class LEA {
- private boolean showStatusWindow;
-
- private boolean shutdown = false;
-
- // private LEAImplementation implementation = new LEAImplementation();
-
- // 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();
- // }
- //
- // }
+ @LOC("IMPL")
+ private LEAImplementation implementation;
+ @LOC("LAST")
+ private FaceAndEyePosition lastPositions = new FaceAndEyePosition(-1,-1,-1,-1, null);
+ @LOC("DEV")
+ private DeviationScanner deviationScanner = new DeviationScanner();
public LEA() {
// this.imageProcessor = new
// ImageProcessor(this.captureDevice.getFrameRate());
- // this.imageProcessor.start();
- LEAImplementation impl = new LEAImplementation();
- System.out.println("Done.");
+ implementation = new LEAImplementation();
}
/**
}
/**
- * 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
*/
public static void main(String[] args) throws Exception {
LEA lea = new LEA();
+ lea.doRun();
+ }
+
+ @LATTICE("THIS<IMG,IMG<C,C*,THISLOC=THIS")
+ public void doRun() {
+
+ @LOC("C") int i = 0;
+
+ SSJAVA: while (true) {
+ @LOC("IMG") Image image = ImageReader.getImage();
+ if (image == null) {
+ break;
+ }
+ processImage(image);
+ }
+
+ System.out.println("Done.");
+
+ }
+
+ 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);
+ }
+ // }
+ lastPositions = positions;
}
}