be45cee383b535b0bb9b2134418967f316bb2c65
[IRC.git] / Robust / src / Benchmarks / SSJava / EyeTrackingInfer / EyePosition.java
1 /*
2  * Copyright 2009 (c) Florian Frankenberger (darkblue.de)
3  * 
4  * This file is part of LEA.
5  * 
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
9  * later version.
10  * 
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
14  * details.
15  * 
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/>.
18  */
19
20 /**
21  * No description given.
22  * 
23  * @author Florian Frankenberger
24  */
25
26 public class EyePosition {
27
28   private int x;
29
30   private int y;
31
32   private Rectangle2D faceRect;
33
34   public EyePosition(Point p, Rectangle2D faceRect) {
35     this(p.x, p.y, faceRect);
36   }
37
38   public EyePosition(int x, int y, Rectangle2D faceRect) {
39     this.x = x;
40     this.y = y;
41     this.faceRect = faceRect;
42   }
43
44   public int getX() {
45     return this.x;
46   }
47
48   public int getY() {
49     return this.y;
50   }
51
52   public String toString() {
53     return "(" + x + "," + y + ")";
54   }
55
56   // public Deviation getDeviation(EyePosition oldEyePosition) {
57   // if (oldEyePosition == null) return Deviation.NONE;
58   //
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;
63   //
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);
67   //
68   // int deviationX = Math.abs(x - oldEyePosition.x);
69   // int directionX = sgn(x - oldEyePosition.x);
70   // if (deviationX < minDeviation || deviationX > maxDeviationX) directionX =
71   // 0;
72   //
73   // int deviationY = Math.abs(y - oldEyePosition.y);
74   // int directionY = sgn(y - oldEyePosition.y);
75   // if (deviationY < minDeviation || deviationY > maxDeviationY) directionY =
76   // 0;
77   //
78   // double deviationXPercent = deviationX / this.faceRect.getWidth();
79   // double deviationYPercent = deviationY / this.faceRect.getWidth();
80   //
81   // System.out.println(String.format("devX: %.2f | devY: %.2f",
82   // deviationXPercent*100f, deviationYPercent*100f));
83   // return Deviation.getDirectionFor(directionX, directionY);
84   // }
85
86   private static int sgn(int i) {
87     if (i > 0)
88       return 1;
89     if (i < 0)
90       return -1;
91     return 0;
92   }
93 }