2 * Copyright 2009 (c) Florian Frankenberger (darkblue.de)
4 * This file is part of LEA.
6 * LEA is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU Lesser General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option) any
11 * LEA is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with LEA. If not, see <http://www.gnu.org/licenses/>.
21 * No description given.
23 * @author Florian Frankenberger
26 public class EyePosition {
32 private Rectangle2D faceRect;
34 public EyePosition(Point p, Rectangle2D faceRect) {
35 this(p.x, p.y, faceRect);
38 public EyePosition(int x, int y, Rectangle2D faceRect) {
41 this.faceRect = faceRect;
52 public String toString() {
53 return "(" + x + "," + y + ")";
56 // public Deviation getDeviation(EyePosition oldEyePosition) {
57 // if (oldEyePosition == null) return Deviation.NONE;
59 // //first we check if the faceRects are corresponding
60 // double widthChange = (this.faceRect.getWidth() -
61 // oldEyePosition.faceRect.getWidth()) / this.faceRect.getWidth();
62 // if (widthChange > 0.1) return Deviation.NONE;
64 // int maxDeviationX = (int)Math.round(this.faceRect.getWidth() / 4f);
65 // int maxDeviationY = (int)Math.round(this.faceRect.getWidth() / 8f);
66 // int minDeviation = (int)Math.round(this.faceRect.getWidth() / 16f);
68 // int deviationX = Math.abs(x - oldEyePosition.x);
69 // int directionX = sgn(x - oldEyePosition.x);
70 // if (deviationX < minDeviation || deviationX > maxDeviationX) directionX =
73 // int deviationY = Math.abs(y - oldEyePosition.y);
74 // int directionY = sgn(y - oldEyePosition.y);
75 // if (deviationY < minDeviation || deviationY > maxDeviationY) directionY =
78 // double deviationXPercent = deviationX / this.faceRect.getWidth();
79 // double deviationYPercent = deviationY / this.faceRect.getWidth();
81 // System.out.println(String.format("devX: %.2f | devY: %.2f",
82 // deviationXPercent*100f, deviationYPercent*100f));
83 // return Deviation.getDirectionFor(directionX, directionY);
86 private static int sgn(int i) {