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
27 public class LEAImplementation {
30 private ClassifierTree classifierTree;
33 public LEAImplementation() {
39 public FaceAndEyePosition getEyePosition( Image image) {
40 return classifierTree.getEyePosition(image);
43 public boolean needsCalibration() {
48 * This method loads the faceData from a file called facedata.dat which should be within the
51 private void loadFaceData() {
53 FileInputStream inputFile = new FileInputStream("facedata.dat");
55 int numClassifier = Integer.parseInt(inputFile.readLine());
56 classifierTree = new ClassifierTree(numClassifier);
57 for (int c = 0; c < numClassifier; c++) {
59 int numArea = Integer.parseInt(inputFile.readLine());
60 Classifier classifier = new Classifier(numArea);
62 for (int idx = 0; idx < numArea; idx++) {
64 Point fromPoint = new Point();
65 Point toPoint = new Point();
66 fromPoint.x = Integer.parseInt(inputFile.readLine());
67 fromPoint.y = Integer.parseInt(inputFile.readLine());
68 toPoint.x = Integer.parseInt(inputFile.readLine());
69 toPoint.y = Integer.parseInt(inputFile.readLine());
70 float size = Float.parseFloat(inputFile.readLine());
71 ScanArea area = new ScanArea(fromPoint, toPoint, size);
72 classifier.setScanArea(idx, area);
75 // parsing possibilities face yes
76 float array[] = new float[numArea];
77 for (int idx = 0; idx < numArea; idx++) {
78 array[idx] = Float.parseFloat(inputFile.readLine());
80 classifier.setPossibilitiesFaceYes(array);
82 // parsing possibilities face no
83 array = new float[numArea];
84 for (int idx = 0; idx < numArea; idx++) {
85 array[idx] = Float.parseFloat(inputFile.readLine());
87 classifier.setPossibilitiesFaceNo(array);
89 classifier.setPossibilityFaceYes(Integer.parseInt(inputFile.readLine()));
90 classifier.setPossibilityFaceNo(Integer.parseInt(inputFile.readLine()));
92 classifierTree.addClassifier(c, classifier);