X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=Robust%2Fsrc%2FBenchmarks%2FSSJava%2FEyeTrackingInfer%2FLEA.java;h=40479eb13d2f377e3f7bd3770b17c53b53274b3b;hb=9d767c1f5cef3242ff67473368e5ad327c340bfa;hp=b3fda528ca22f3fbb7132eed91fb559a90b00939;hpb=8d750e51bc5fa6b54ed568859dd8a6a25ad9e4c4;p=IRC.git diff --git a/Robust/src/Benchmarks/SSJava/EyeTrackingInfer/LEA.java b/Robust/src/Benchmarks/SSJava/EyeTrackingInfer/LEA.java index b3fda528..40479eb1 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTrackingInfer/LEA.java +++ b/Robust/src/Benchmarks/SSJava/EyeTrackingInfer/LEA.java @@ -20,19 +20,22 @@ /** * This is the main class of LEA. *
- * It uses a face detection algorithm to find an a face within the provided image(s). Then it - * searches for the eye in a region where it most likely located and traces its position relative to - * the face and to the last known position. The movements are estimated by comparing more than one - * movement. If a movement is distinctly pointing to a direction it is recognized and all listeners - * get notified. + * It uses a face detection algorithm to find an a face within the provided + * image(s). Then it searches for the eye in a region where it most likely + * located and traces its position relative to the face and to the last known + * position. The movements are estimated by comparing more than one movement. If + * a movement is distinctly pointing to a direction it is recognized and all + * listeners get notified. *
* The notification is designed as observer pattern. You simply call
- * addEyeMovementListener(IEyeMovementListener)
to add an implementation of
- * IEyeMovementListener
to LEA. When a face is recognized/lost or whenever an eye
- * movement is detected LEA will call the appropriate methods of the listener
+ * addEyeMovementListener(IEyeMovementListener)
to add an
+ * implementation of IEyeMovementListener
to LEA. When a face is
+ * recognized/lost or whenever an eye movement is detected LEA will call the
+ * appropriate methods of the listener
*
- * LEA also needs an image source implementing the ICaptureDevice
. One image source
- * proxy to the Java Media Framework
is included ( JMFCaptureDevice
).
+ * LEA also needs an image source implementing the ICaptureDevice
.
+ * One image source proxy to the Java Media Framework
is included (
+ * JMFCaptureDevice
).
*
* Example (for using LEA with Java Media Framework
):
*
@@ -40,19 +43,22 @@ * LEA lea = new LEA(new JMFCaptureDevice(), true); * *
- * This will start LEA with the first available JMF datasource with an extra status window showing
- * if face/eye has been detected successfully. Please note that face detection needs about 2 seconds
- * to find a face. After detection the following face detection is much faster.
+ * This will start LEA with the first available JMF datasource with an extra
+ * status window showing if face/eye has been detected successfully. Please note
+ * that face detection needs about 2 seconds to find a face. After detection the
+ * following face detection is much faster.
*
* @author Florian Frankenberger
*/
+
public class LEA {
+
private LEAImplementation implementation;
-
- private FaceAndEyePosition lastPositions = new FaceAndEyePosition(null, null);
-
+
+ private FaceAndEyePosition lastPositions = new FaceAndEyePosition(-1,-1,-1,-1, null);
+
private DeviationScanner deviationScanner = new DeviationScanner();
public LEA() {
@@ -62,17 +68,18 @@ public class LEA {
}
/**
- * Clears the internal movement buffer. If you just capture some of the eye movements you should
- * call this every time you start recording the movements. Otherwise you may get notified for
- * movements that took place BEFORE you started recording.
+ * Clears the internal movement buffer. If you just capture some of the eye
+ * movements you should call this every time you start recording the
+ * movements. Otherwise you may get notified for movements that took place
+ * BEFORE you started recording.
*/
public void clear() {
// this.imageProcessor.clearDeviationScanner();
}
/**
- * @METHOD To test LEA with the first capture device from the Java Media Framework
- * just start from here.
+ * @METHOD To test LEA with the first capture device from the
+ * Java Media Framework
just start from here.
*
* @param args
* @throws Exception
@@ -82,12 +89,13 @@ public class LEA {
lea.doRun();
}
+
public void doRun() {
- int i = 0;
+ int i = 0;
SSJAVA: while (true) {
- Image image = ImageReader.getImage();
+ Image image = ImageReader.getImage();
if (image == null) {
break;
}
@@ -97,12 +105,13 @@ public class LEA {
System.out.println("Done.");
}
+
- private void processImage(Image image) {
- FaceAndEyePosition positions = implementation.getEyePosition(image);
+ private void processImage( Image image) {
+ FaceAndEyePosition positions = implementation.getEyePosition(image);
// if (positions.getEyePosition() != null) {
deviationScanner.addEyePosition(positions.getEyePosition());
- int deviation = deviationScanner.scanForDeviation(positions.getFacePosition());// positions.getEyePosition().getDeviation(lastPositions.getEyePosition());
+ int deviation = deviationScanner.scanForDeviation(positions.getFacePosition());// positions.getEyePosition().getDeviation(lastPositions.getEyePosition());
if (deviation != DeviationScanner.NONE) {
System.out.println("deviation=" + deviationScanner.toStringDeviation(deviation));
// notifyEyeMovementListenerEyeMoved(deviation);