From 835736146e4bd56942706d7c0957358bf180ec25 Mon Sep 17 00:00:00 2001 From: yeom Date: Fri, 16 Sep 2011 23:29:02 +0000 Subject: [PATCH] EyeTracking has the same result of the original Java version. --- .../SSJava/EyeTracking/Deviation.java | 4 ++ .../SSJava/EyeTracking/DeviationScanner.java | 18 ++++---- .../SSJava/EyeTracking/EyeDetector.java | 9 ---- .../Benchmarks/SSJava/EyeTracking/LEA.java | 6 +-- .../SSJava/EyeTracking/LEAImplementation.java | 7 +-- .../src/Benchmarks/SSJava/EyeTracking/output | 44 +++++++++++++++++++ 6 files changed, 62 insertions(+), 26 deletions(-) create mode 100644 Robust/src/Benchmarks/SSJava/EyeTracking/output diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/Deviation.java b/Robust/src/Benchmarks/SSJava/EyeTracking/Deviation.java index ff10c62c..41e3c7a5 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/Deviation.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/Deviation.java @@ -52,4 +52,8 @@ public class Deviation { return false; } + public String toString() { + return direction; + } + } diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/DeviationScanner.java b/Robust/src/Benchmarks/SSJava/EyeTracking/DeviationScanner.java index 456e3d12..dfabadee 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/DeviationScanner.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/DeviationScanner.java @@ -30,15 +30,15 @@ public class DeviationScanner { // RIGHT(-1, 0), LEFT_DOWN( // +1, +1), DOWN(0, +1), RIGHT_DOWN(-1, +1); - private static final Deviation LEFT_UP = new Deviation("NONE", +1, -1); + private static final Deviation LEFT_UP = new Deviation("LEFT_UP", +1, -1); private static final Deviation UP = new Deviation("UP", 0, -1); private static final Deviation RIGHT_UP = new Deviation("RIGHT_UP", -1, -1); private static final Deviation LEFT = new Deviation("LEFT", +1, 0); private static final Deviation NONE = new Deviation("NONE", 0, 0); - private static final Deviation RIGHT = new Deviation("NONE", -1, 0); - private static final Deviation LEFT_DOWN = new Deviation("NONE", +1, +1); - private static final Deviation DOWN = new Deviation("NONE", 0, +1); - private static final Deviation RIGHT_DOWN = new Deviation("NONE", -1, +1); + private static final Deviation RIGHT = new Deviation("RIGHT", -1, 0); + private static final Deviation LEFT_DOWN = new Deviation("LEFT_DOWN", +1, +1); + private static final Deviation DOWN = new Deviation("DOWN", 0, +1); + private static final Deviation RIGHT_DOWN = new Deviation("RIGHT_DOWN", -1, +1); private int size; @@ -49,10 +49,10 @@ public class DeviationScanner { public void addEyePosition(EyePosition eyePosition) { - for (int i = eyePositions.length - 2; i >= 0; i--) { - eyePositions[i + 1] = eyePositions[i]; + for (int i = 1; i < eyePositions.length; i++) { + eyePositions[i - 1] = eyePositions[i]; } - eyePositions[0] = eyePosition; + eyePositions[eyePositions.length - 1] = eyePosition; if (size < eyePositions.length) { size++; @@ -72,7 +72,6 @@ public class DeviationScanner { EyePosition lastEyePosition = null; for (int i = 0; i < 3; ++i) { EyePosition eyePosition = this.eyePositions[i]; - System.out.println("lastEyePosition=" + lastEyePosition); if (lastEyePosition != null) { deviationX += (eyePosition.getX() - lastEyePosition.getX()); deviationY += (eyePosition.getY() - lastEyePosition.getY()); @@ -98,6 +97,7 @@ public class DeviationScanner { deviationAbsoluteY = -1; deviation = getDirectionFor(deviationAbsoluteX, deviationAbsoluteY); + if (deviation != NONE) { eyePositions = new EyePosition[3]; size = 0; diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/EyeDetector.java b/Robust/src/Benchmarks/SSJava/EyeTracking/EyeDetector.java index faf53f73..22171742 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/EyeDetector.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/EyeDetector.java @@ -41,13 +41,6 @@ class EyeDetector { height = (int) faceRect.getHeight() / 2; pixelBuffer = new int[width * height]; - // System.out.println("eye w=" + width + " h=" + height); - // System.out - // .println("faceRect.getX()=" + faceRect.getX() + " faceRect.getY()=" + - // faceRect.getY()); - // System.out.println("image w=" + image.getWidth() + " h=" + - // image.getHeight()); - int startX = (int) faceRect.getX(); int startY = (int) faceRect.getY(); @@ -78,8 +71,6 @@ class EyeDetector { } } - System.out.println("eyePosition=" + eyePosition); - return eyePosition; } diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/LEA.java b/Robust/src/Benchmarks/SSJava/EyeTracking/LEA.java index fed080cf..3aad7e86 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/LEA.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/LEA.java @@ -172,13 +172,13 @@ public class LEA { public void doRun() { - int maxCount = 1; + int maxCount = 37; int i = 0; ImageReader reader = new ImageReader(); while (i < maxCount) { - Image image = reader.readImage("data/e" + i + ".bmp"); + Image image = reader.readImage("data/b" + i + ".bmp"); i++; if (image == null) { break; @@ -198,7 +198,7 @@ public class LEA { deviationScanner.addEyePosition(positions.getEyePosition()); Deviation deviation = deviationScanner.scanForDeviation(positions.getFacePosition());// positions.getEyePosition().getDeviation(lastPositions.getEyePosition()); if (deviation != DeviationScanner.NONE) { - System.out.println("DEVICATION=" + deviation); + System.out.println("deviation=" + deviation); // notifyEyeMovementListenerEyeMoved(deviation); } } diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/LEAImplementation.java b/Robust/src/Benchmarks/SSJava/EyeTracking/LEAImplementation.java index 50e6d016..fe81654e 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/LEAImplementation.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/LEAImplementation.java @@ -37,18 +37,16 @@ public class LEAImplementation { return null; Rectangle2D faceRect = classifierTree.locateFaceRadial(image, lastRectangle); - System.out.println("FACE RECT=" + faceRect); EyePosition eyePosition = null; if (faceRect != null) { - lastRectangle = faceRect; Point point = readEyes(image, faceRect); if (point != null) { eyePosition = new EyePosition(point, faceRect); } } - System.out.println("eyePosition="+eyePosition); - + System.out.println("eyePosition=" + eyePosition); + return new FaceAndEyePosition(faceRect, eyePosition); } @@ -72,7 +70,6 @@ public class LEAImplementation { classifierTree = new ClassifierTree(); int numClassifier = Integer.parseInt(inputFile.readLine()); - System.out.println("numClassifier=" + numClassifier); for (int c = 0; c < numClassifier; c++) { int numArea = Integer.parseInt(inputFile.readLine()); diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/output b/Robust/src/Benchmarks/SSJava/EyeTracking/output new file mode 100644 index 00000000..6fcc5d69 --- /dev/null +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/output @@ -0,0 +1,44 @@ +eyePosition=(89,72) +eyePosition=(91,75) +eyePosition=(91,70) +eyePosition=(91,70) +eyePosition=(98,79) +eyePosition=(100,79) +eyePosition=(98,77) +eyePosition=(98,77) +eyePosition=(117,84) +deviation=LEFT +eyePosition=(120,78) +eyePosition=(121,79) +eyePosition=(121,76) +eyePosition=(119,78) +eyePosition=(120,79) +eyePosition=(119,77) +eyePosition=(119,77) +eyePosition=(121,79) +eyePosition=(72,80) +deviation=RIGHT +eyePosition=(105,84) +eyePosition=(73,82) +eyePosition=(120,81) +deviation=LEFT +eyePosition=(119,78) +eyePosition=(119,78) +eyePosition=(119,78) +eyePosition=(121,81) +eyePosition=(121,81) +eyePosition=(71,81) +deviation=RIGHT +eyePosition=(71,81) +eyePosition=(121,81) +eyePosition=(121,81) +deviation=LEFT +eyePosition=(119,80) +eyePosition=(119,81) +eyePosition=(97,81) +deviation=RIGHT +eyePosition=(92,80) +eyePosition=(92,81) +eyePosition=(92,80) +eyePosition=(92,80) +Done. -- 2.34.1