Пример #1
1
 public void testExtractionAndMetric()
     throws IOException, IllegalAccessException, InstantiationException {
   for (Class c : featureClasses) {
     LireFeature lireFeature = (LireFeature) c.newInstance();
     LireFeature tmpLireFeature = (LireFeature) c.newInstance();
     for (String file : testFiles) {
       System.out.println(c.getName() + ": " + file);
       BufferedImage image = ImageIO.read(new FileInputStream(testFilesPath + file));
       //                image = ImageUtils.trimWhiteSpace(image);
       lireFeature.extract(image);
       float delta = 0.0000f;
       assertEquals(lireFeature.getDistance(lireFeature), 0, delta);
       //
       // tmpLireFeature.setStringRepresentation(lireFeature.getStringRepresentation());
       //                assertEquals(lireFeature.getDistance(tmpLireFeature), 0, delta);
       tmpLireFeature.setByteArrayRepresentation(lireFeature.getByteArrayRepresentation());
       assertEquals(lireFeature.getDistance(tmpLireFeature), 0, delta);
       tmpLireFeature.setByteArrayRepresentation(
           lireFeature.getByteArrayRepresentation(),
           0,
           lireFeature.getByteArrayRepresentation().length);
       assertEquals(lireFeature.getDistance(tmpLireFeature), 0, delta);
     }
   }
 }
Пример #2
0
 public void testReUse() throws IOException, IllegalAccessException, InstantiationException {
   ArrayList<String> testFiles = FileUtils.getAllImages(new File("testdata/ferrari"), true);
   for (Class c : featureClasses) {
     LireFeature f1 = (LireFeature) c.newInstance();
     System.out.println(c.getName());
     for (String testFile : testFiles) {
       f1.extract(ImageIO.read(new File(testFile)));
       LireFeature f2 = (LireFeature) c.newInstance();
       f2.extract(ImageIO.read(new File(testFile)));
       //                System.out.println(Arrays.toString(f1.getDoubleHistogram()));
       //                System.out.println(Arrays.toString(f2.getDoubleHistogram()));
       assertEquals(f2.getDistance(f1), 0d, 0.000000001);
       f2.setByteArrayRepresentation(f1.getByteArrayRepresentation());
       assertEquals(f2.getDistance(f1), 0d, 0.000000001);
       byte[] tmp = new byte[1024 * 100];
       Arrays.fill(tmp, (byte) 0x000F);
       byte[] bytes = f1.getByteArrayRepresentation();
       System.arraycopy(bytes, 0, tmp, 12, bytes.length);
       f2.setByteArrayRepresentation(tmp, 12, bytes.length);
       assertEquals(f2.getDistance(f1), 0d, 0.000000001);
     }
   }
 }