Exemple #1
0
  public static void preprocess(Map<String, ImageData> images) throws IOException {
    File cacheFile = new File(colorHistCacheFile);
    if (cacheFile.exists()) {
      try (BufferedReader br = new BufferedReader(new FileReader(colorHistCacheFile))) {
        String line = br.readLine();

        while (line != null) {
          double[] bins = new double[dim * dim * dim];
          String key = line.substring(0, line.indexOf(" "));
          String values = line.substring(line.indexOf("[") + 1, line.indexOf("]"));
          String binS[] = values.split(",\\s");
          for (int i = 0; i < binS.length; i++) {
            bins[i] = Double.parseDouble(binS[i]);
          }
          images.get(key).setColorHistogram(bins);
          line = br.readLine();
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
    } else {
      try (BufferedWriter bw = new BufferedWriter(new FileWriter(colorHistCacheFile))) {
        for (ImageData id : images.values()) {
          double[] colorHistogram = getHist(id);
          id.setColorHistogram(colorHistogram);

          String line = String.format("%s %s%n", id.getFilename(), Arrays.toString(colorHistogram));
          bw.write(line);
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
Exemple #2
0
 public void updateImage(ImageData imageData) throws Exception {
   fUpdateTopicContent.setString(1, imageData.getUrl());
   fUpdateTopicContent.setString(2, imageData.getFilename());
   fUpdateTopicContent.setString(3, imageData.getName());
   fUpdateTopicContent.execute();
 }
Exemple #3
0
 public void insertImage(ImageData imageData) throws Exception {
   fInsertImage.setString(1, imageData.getName());
   fInsertImage.setString(2, imageData.getUrl());
   fInsertImage.setString(3, imageData.getFilename());
   fInsertImage.execute();
 }