コード例 #1
0
 private void readImages(String folderpath) {
   String test = "";
   int offset = 0;
   // get words from db
   String sql = "SELECT word, id FROM word LIMIT " + NUM_CLASSES + " OFFSET " + offset;
   wordClasses = new String[NUM_CLASSES];
   int classes[] = new int[NUM_CLASSES];
   int index = 0;
   try {
     ResultSet rs = db.select(sql);
     while (rs.next()) {
       wordClasses[index] = rs.getString("word");
       classes[index] = rs.getInt("id");
       index++;
     }
   } catch (ClassNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   int number = 0;
   String data2 = "";
   for (int j = 0; j < wordClasses.length; j++) {
     System.out.println(j);
     int files = new File(folderpath + "\\" + wordClasses[j]).listFiles().length;
     for (int k = 1; k <= files; k++) {
       File file = new File(folderpath + "\\" + wordClasses[j] + "\\" + "word (" + k + ").jpg");
       Shorthand word = new Shorthand(file, wordClasses[j], classes[j]);
       testingSamples.add(word);
     }
   }
 }
コード例 #2
0
  public TestingPanel(MainPanel1 card) {
    this.setBackground(Color.white);
    this.setLayout(null);
    this.card = card;
    db = new WordDB();
    wordClasses = new String[NUM_CLASSES];
    for (int i = 0; i < NUM_CLASSES; i++) {
      try {
        wordClasses[i] = db.getWord(i + 1);
      } catch (ClassNotFoundException | SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
    addHeaderComponents();
    addComponents();
    p = new Preprocessing(NUM_CLASSES);

    testingSamples = new ArrayList<Shorthand>();
    r = new WordRecognizer();
  }
コード例 #3
0
  private void readImages2(String folderpath) throws ClassNotFoundException, SQLException {
    // iterate on each folders inside the folder
    File[] files = new File(folderpath).listFiles();

    wordClasses = new String[NUM_CLASSES];
    int classes[] = new int[NUM_CLASSES];
    int i = 0;
    for (File file : files) {
      if (file.isDirectory()) {

        // search in the database
        wordClasses[i] = file.getName();
        classes[i] = db.getIndex(wordClasses[i]);
        File[] wordFolder = file.listFiles();
        for (File wordImage : wordFolder) {
          Shorthand word = new Shorthand(wordImage, wordClasses[i], classes[i]);
          testingSamples.add(word);
        }

        i++;
      }
    }
  }