public boolean train() {
   if (personCount == personLimit) {
     recogniser.train(trainingImages, labels);
     trained = true;
   }
   return trained;
 }
 public String recognise(IplImage aImage) {
   String name = null;
   if (trained) {
     int result = recogniser.predict((CvArr) aImage);
     if (names.containsKey(Integer.valueOf(result))) {
       name = (String) names.get(Integer.valueOf(result));
     }
   }
   return name;
 }
 public void saveTrainingData(String aPath) {
   recogniser.save(aPath + TR_DATA_FILE);
   try {
     ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(aPath + TR_NAMES_FILE));
     os.writeObject(names);
     os.close();
     os.flush();
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
 @SuppressWarnings("unchecked")
 public void loadTrainingDate(String aPath) {
   recogniser.load(aPath + TR_DATA_FILE);
   try {
     ObjectInputStream is = new ObjectInputStream(new FileInputStream(aPath + TR_NAMES_FILE));
     names = (Map<Integer, String>) is.readObject();
     is.close();
   } catch (FileNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (ClassNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   trained = true;
 }