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 @METHODDEFAULT("OUT<THIS,THIS<IN,THISLOC=THIS,RETURNLOC=OUT")
27 public class LEAImplementation {
30 private ClassifierTree classifierTree;
32 public LEAImplementation() {
36 @LATTICE("OUT<V,V<THIS,THIS<IN,V*,THISLOC=THIS,RETURNLOC=OUT")
38 public FaceAndEyePosition getEyePosition(@LOC("IN") Image image) {
39 return classifierTree.getEyePosition(image);
42 public boolean needsCalibration() {
47 * This method loads the faceData from a file called facedata.dat which should be within the
50 private void loadFaceData() {
52 FileInputStream inputFile = new FileInputStream("facedata.dat");
54 int numClassifier = Integer.parseInt(inputFile.readLine());
55 classifierTree = new ClassifierTree(numClassifier);
56 for (int c = 0; c < numClassifier; c++) {
58 int numArea = Integer.parseInt(inputFile.readLine());
59 Classifier classifier = new Classifier(numArea);
61 for (int idx = 0; idx < numArea; idx++) {
63 Point fromPoint = new Point();
64 Point toPoint = new Point();
65 fromPoint.x = Integer.parseInt(inputFile.readLine());
66 fromPoint.y = Integer.parseInt(inputFile.readLine());
67 toPoint.x = Integer.parseInt(inputFile.readLine());
68 toPoint.y = Integer.parseInt(inputFile.readLine());
69 float size = Float.parseFloat(inputFile.readLine());
70 ScanArea area = new ScanArea(fromPoint, toPoint, size);
71 classifier.setScanArea(idx, area);
74 // parsing possibilities face yes
75 float array[] = new float[numArea];
76 for (int idx = 0; idx < numArea; idx++) {
77 array[idx] = Float.parseFloat(inputFile.readLine());
79 classifier.setPossibilitiesFaceYes(array);
81 // parsing possibilities face no
82 array = new float[numArea];
83 for (int idx = 0; idx < numArea; idx++) {
84 array[idx] = Float.parseFloat(inputFile.readLine());
86 classifier.setPossibilitiesFaceNo(array);
88 classifier.setPossibilityFaceYes(Integer.parseInt(inputFile.readLine()));
89 classifier.setPossibilityFaceNo(Integer.parseInt(inputFile.readLine()));
91 classifierTree.addClassifier(c, classifier);