1000) {
- return null;
+ px = -1;
+ py = -1;
+ pwidth = -1;
+ pheight = -1;
+ return;
}
- @LOC("THIS,ClassifierTree.C") float factor = startFactor + factorDiff;
+ @LOC("THIS,ClassifierTree.CUR") float factor = startFactor + factorDiff;
if (factor > maxScaleFactor || factor < minScaleFactor)
continue;
// now we calculate the actualDimmension
- @LOC("THIS,ClassifierTree.C") int actualDimmension = (int) (100 * factor);
- @LOC("THIS,ClassifierTree.C") int maxX = imageData.getWidth() - actualDimmension;
- @LOC("THIS,ClassifierTree.C") int maxY = imageData.getHeight() - actualDimmension;
+ @LOC("THIS,ClassifierTree.CUR") int actualDimmension = (int) (100 * factor);
+ @LOC("THIS,ClassifierTree.CUR") int maxX = imageData.getWidth() - actualDimmension;
+ @LOC("THIS,ClassifierTree.CUR") int maxY = imageData.getHeight() - actualDimmension;
- @LOC("THIS,ClassifierTree.C") int maxDiffX = Math.max(Math.abs(startPosX - maxX), startPosX);
- @LOC("THIS,ClassifierTree.C") int maxDiffY = Math.max(Math.abs(startPosY - maxY), startPosY);
+ @LOC("THIS,ClassifierTree.CUR") int maxDiffX =
+ Math.max(Math.abs(startPosX - maxX), startPosX);
+ @LOC("THIS,ClassifierTree.CUR") int maxDiffY =
+ Math.max(Math.abs(startPosY - maxY), startPosY);
- @LOC("CXY") int xidx = 0;
- TERMINATE: for (@LOC("CXY") float xDiff = 0.1f; Math.abs(xDiff) <= maxDiffX; xDiff =
+ @LOC("THIS,ClassifierTree.CUR") int xidx = 0;
+ TERMINATE: for (@LOC("THIS,ClassifierTree.CUR") float xDiff = 0.1f; Math.abs(xDiff) <= maxDiffX; xDiff =
(xDiff + sgn(xDiff) * 0.5f) * -1) {
if (++xidx > 1000) {
- return null;
+ px = -1;
+ py = -1;
+ pwidth = -1;
+ pheight = -1;
+ return;
}
- @LOC("CXY") int xPos = Math.round((float) (startPosX + xDiff));
+ @LOC("THIS,ClassifierTree.CUR") int xPos = Math.round((float) (startPosX + xDiff));
if (xPos < 0 || xPos > maxX)
continue;
- @LOC("CXY") int yidx = 0;
+ @LOC("THIS,ClassifierTree.CUR") int yidx = 0;
// yLines:
- TERMINATE: for (@LOC("CXY") float yDiff = 0.1f; Math.abs(yDiff) <= maxDiffY; yDiff =
+ TERMINATE: for (@LOC("THIS,ClassifierTree.CUR") float yDiff = 0.1f; Math.abs(yDiff) <= maxDiffY; yDiff =
(yDiff + sgn(yDiff) * 0.5f) * -1) {
if (++yidx > 1000) {
- return null;
+ px = -1;
+ py = -1;
+ pwidth = -1;
+ pheight = -1;
+ return;
}
- @LOC("CXY") int yPos = Math.round(startPosY + yDiff);
+ @LOC("THIS,ClassifierTree.CUR") int yPos = Math.round(startPosY + yDiff);
if (yPos < 0 || yPos > maxY)
continue;
// by now we should have a valid coordinate to process which we should
// do now
- @LOC("CXY") boolean backToYLines = false;
- for (@LOC("CXY") int idx = 0; idx < classifiers.length; ++idx) {
- @LOC("CXY") float borderline =
- 0.8f + (idx / (classifiers.length - 1)) * (maxBorder - 0.8f);
+ @LOC("THIS,ClassifierTree.C") boolean backToYLines = false;
+ for (@LOC("THIS,ClassifierTree.CUR") int idx = 0; idx < size; ++idx) {
+ @LOC("THIS,ClassifierTree.CUR") float borderline =
+ 0.8f + (idx / (size - 1)) * (maxBorder - 0.8f);
if (!classifiers[idx].classifyFace(imageData, factor, xPos, yPos, borderline)) {
backToYLines = true;
break;
@@ -167,11 +209,12 @@ public class ClassifierTree {
if (backToYLines) {
continue;
}
- @LOC("OUT") Rectangle2D faceRect =
- new Rectangle2D(xPos * originalImageFactor, yPos * originalImageFactor,
- actualDimmension * originalImageFactor, actualDimmension * originalImageFactor);
- return faceRect;
+ x = xPos * originalImageFactor;
+ y = yPos * originalImageFactor;
+ width = actualDimmension * originalImageFactor;
+ height = actualDimmension * originalImageFactor;
+ return;
}
@@ -180,7 +223,7 @@ public class ClassifierTree {
}
// System.out.println("Time: "+(System.currentTimeMillis()-timeStart)+"ms");
- return null;
+ // return null;
}
@@ -190,4 +233,36 @@ public class ClassifierTree {
return (value < 0 ? -1 : (value > 0 ? +1 : 1));
}
+ @LATTICE("OUT image.getWidth() || height > image.getHeight()) {
+ return null;
+ }
+
+ @LOC("OUT") EyePosition eyePosition = null;
+
+ if (x != -1) {
+ @LOC("ED") EyeDetector ed = new EyeDetector(image, x, y, width, height);
+ @LOC("P") Point point = ed.detectEye();
+ if (point != null) {
+ eyePosition = new EyePosition(point.getX(), point.getY());
+ }
+ }
+
+ System.out.println("eyePosition=" + eyePosition);
+
+ @LOC("OUT") FaceAndEyePosition fep = new FaceAndEyePosition(x, y, width, height, eyePosition);
+
+ return fep;
+ }
+
+
}