changes toward compilation
[IRC.git] / Robust / src / Benchmarks / SSJava / EyeTracking / 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 /**
22  * No description given.
23  * 
24  * @author Florian Frankenberger
25  */
26 public class EyePosition {
27     private int x;
28     private int y;
29     private Rectangle2D faceRect;
30
31     public EyePosition(Point p, Rectangle2D faceRect) {
32         this(p.x, p.y, faceRect);
33     }
34     
35     public EyePosition(int x, int y, Rectangle2D faceRect) {
36         this.x = x;
37         this.y = y;
38         this.faceRect = faceRect;
39     }
40
41     public int getX() {
42         return this.x;
43     }
44
45     public int getY() {
46         return this.y;
47     }
48     
49 //    public Deviation getDeviation(EyePosition oldEyePosition) {
50 //        if (oldEyePosition == null) return Deviation.NONE;
51 //
52 //        //first we check if the faceRects are corresponding
53 //        double widthChange = (this.faceRect.getWidth() - oldEyePosition.faceRect.getWidth()) / this.faceRect.getWidth();
54 //        if (widthChange > 0.1) return Deviation.NONE;
55 //
56 //        int maxDeviationX = (int)Math.round(this.faceRect.getWidth() / 4f);
57 //        int maxDeviationY = (int)Math.round(this.faceRect.getWidth() / 8f);
58 //        int minDeviation = (int)Math.round(this.faceRect.getWidth() / 16f);
59 //
60 //        int deviationX = Math.abs(x - oldEyePosition.x);
61 //        int directionX = sgn(x - oldEyePosition.x);
62 //        if (deviationX < minDeviation || deviationX > maxDeviationX) directionX = 0;
63 //
64 //        int deviationY = Math.abs(y - oldEyePosition.y);
65 //        int directionY = sgn(y - oldEyePosition.y);
66 //        if (deviationY < minDeviation || deviationY > maxDeviationY) directionY = 0;
67 //
68 //        double deviationXPercent = deviationX / this.faceRect.getWidth();
69 //        double deviationYPercent = deviationY / this.faceRect.getWidth();
70 //        
71 //        System.out.println(String.format("devX: %.2f | devY: %.2f", deviationXPercent*100f, deviationYPercent*100f));
72 //        return Deviation.getDirectionFor(directionX, directionY);
73 //    }
74
75
76     private static int sgn(int i) {
77         if (i > 0) return 1;
78         if (i < 0) return -1;
79         return 0;
80     }
81 }