changes: 1) fixes problems in the original EyeTracking benchmark 2) fix a bug in...
[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
27 public class EyePosition {
28   
29   private int x;
30   
31   private int y;
32  
33    private double facex;
34    private double facey;
35    private double facewidth;
36    private double faceheight;
37
38   // private Rectangle2D faceRect;
39
40   // public EyePosition(Point p, Rectangle2D faceRect) {
41   // this(p.x, p.y, faceRect);
42   // }
43   //
44   // public EyePosition(int x, int y, Rectangle2D faceRect) {
45   // this.x = x;
46   // this.y = y;
47   // this.faceRect = faceRect;
48   // }
49
50   public EyePosition(int x, int y) {
51     this.x = x;
52     this.y = y;
53   }
54
55   public int getX() {
56     return this.x;
57   }
58
59   public int getY() {
60     return this.y;
61   }
62
63   public String toString() {
64     return "(" + x + "," + y + ")";
65   }
66
67   // public Deviation getDeviation(EyePosition oldEyePosition) {
68   // if (oldEyePosition == null) return Deviation.NONE;
69   //
70   // //first we check if the faceRects are corresponding
71   // double widthChange = (this.faceRect.getWidth() -
72   // oldEyePosition.faceRect.getWidth()) / this.faceRect.getWidth();
73   // if (widthChange > 0.1) return Deviation.NONE;
74   //
75   // int maxDeviationX = (int)Math.round(this.faceRect.getWidth() / 4f);
76   // int maxDeviationY = (int)Math.round(this.faceRect.getWidth() / 8f);
77   // int minDeviation = (int)Math.round(this.faceRect.getWidth() / 16f);
78   //
79   // int deviationX = Math.abs(x - oldEyePosition.x);
80   // int directionX = sgn(x - oldEyePosition.x);
81   // if (deviationX < minDeviation || deviationX > maxDeviationX) directionX =
82   // 0;
83   //
84   // int deviationY = Math.abs(y - oldEyePosition.y);
85   // int directionY = sgn(y - oldEyePosition.y);
86   // if (deviationY < minDeviation || deviationY > maxDeviationY) directionY =
87   // 0;
88   //
89   // double deviationXPercent = deviationX / this.faceRect.getWidth();
90   // double deviationYPercent = deviationY / this.faceRect.getWidth();
91   //
92   // System.out.println(String.format("devX: %.2f | devY: %.2f",
93   // deviationXPercent*100f, deviationYPercent*100f));
94   // return Deviation.getDirectionFor(directionX, directionY);
95   // }
96
97   private static int sgn(int i) {
98     if (i > 0)
99       return 1;
100     if (i < 0)
101       return -1;
102     return 0;
103   }
104 }