Exemplo n.º 1
0
 private int[] getHashes(LireFeature feature) {
   // result = new int[maximumHits];
   hashingResultScoreDocs.clear();
   maxDistance = 0f;
   tmpScore = 0f;
   int rep = 0;
   LireFeature tmpFeature;
   for (Iterator<LireFeature> iterator = representatives.iterator(); iterator.hasNext(); ) {
     tmpFeature = iterator.next();
     tmpScore = tmpFeature.getDistance(feature);
     if (hashingResultScoreDocs.size() < maximumHits) {
       hashingResultScoreDocs.add(new SimpleResult(tmpScore, null, rep));
       maxDistance = Math.max(maxDistance, tmpScore);
     } else if (tmpScore < maxDistance) {
       hashingResultScoreDocs.add(new SimpleResult(tmpScore, null, rep));
     }
     while (hashingResultScoreDocs.size() > maximumHits) {
       hashingResultScoreDocs.remove(hashingResultScoreDocs.last());
       maxDistance = hashingResultScoreDocs.last().getDistance();
     }
     rep++;
   }
   rep = 0;
   for (Iterator<SimpleResult> iterator = hashingResultScoreDocs.iterator();
       iterator.hasNext(); ) {
     SimpleResult next = iterator.next();
     result[rep] = next.getIndexNumber();
     rep++;
   }
   return result;
 }
  public LocalFeatureExtractor extractLocalFeatures(
      BufferedImage image, LocalFeatureExtractor localFeatureExtractor) {
    assert (image != null);
    // Scaling image is especially with the correlogram features very important!
    // All images are scaled to guarantee a certain upper limit for indexing.
    if (Math.max(image.getHeight(), image.getWidth()) > DocumentBuilder.MAX_IMAGE_DIMENSION) {
      image = ImageUtils.scaleImage(image, DocumentBuilder.MAX_IMAGE_DIMENSION);
    }

    localFeatureExtractor.extract(image);
    return localFeatureExtractor;
  }
Exemplo n.º 3
0
 private void readIndexInputFullyWithRandomSeeks(IndexInput indexInput) throws IOException {
   BytesRef ref = new BytesRef(scaledRandomIntBetween(1, 1024));
   long pos = 0;
   while (pos < indexInput.length()) {
     assertEquals(pos, indexInput.getFilePointer());
     int op = random().nextInt(5);
     if (op == 0) {
       int shift = 100 - randomIntBetween(0, 200);
       pos = Math.min(indexInput.length() - 1, Math.max(0, pos + shift));
       indexInput.seek(pos);
     } else if (op == 1) {
       indexInput.readByte();
       pos++;
     } else {
       int min = (int) Math.min(indexInput.length() - pos, ref.bytes.length);
       indexInput.readBytes(ref.bytes, ref.offset, min);
       pos += min;
     }
   }
 }