X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=Robust%2Fsrc%2FBenchmarks%2FSSJava%2FEyeTracking%2FClassifierTree.java;h=3c7c94e682062db2be33dcc4b3481df6b99c8dc4;hb=9d767c1f5cef3242ff67473368e5ad327c340bfa;hp=fa69d23518a887ea5c49c6272a7e52c9a4516002;hpb=8d750e51bc5fa6b54ed568859dd8a6a25ad9e4c4;p=IRC.git diff --git a/Robust/src/Benchmarks/SSJava/EyeTracking/ClassifierTree.java b/Robust/src/Benchmarks/SSJava/EyeTracking/ClassifierTree.java index fa69d235..3c7c94e6 100644 --- a/Robust/src/Benchmarks/SSJava/EyeTracking/ClassifierTree.java +++ b/Robust/src/Benchmarks/SSJava/EyeTracking/ClassifierTree.java @@ -14,7 +14,10 @@ import SSJava.PCLOC; * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. - * + * private Point readEyes(@LOC("IN") Image image, @LOC("IN") Rectangle2D rect) { + @LOC("OUT") EyeDetector ed = new EyeDetector(image, rect); + return ed.detectEye(); + } * You should have received a copy of the GNU Lesser General Public License * along with LEA. If not, see . */ @@ -23,15 +26,33 @@ import SSJava.PCLOC; * * @author Florian */ -@LATTICE("CS - * TODO: This method could quite possible be tweaked so that face recognition - * would be much faster + * TODO: This method could quite possible be tweaked so that face recognition would be much faster * * @param image * the image to process * @param lastCoordinates * the last known coordinates or null if unknown - * @return an rectangle representing the actual face position on success or - * null if no face could be detected + * @return an rectangle representing the actual face position on success or null if no face could + * be detected */ @LATTICE("OUT 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; + } + + }