LocalFeaturesTool { public static void main(String [] args) throws IOException { LocalFeaturesToolOptions options = new LocalFeaturesToolOptions(); CmdLineParser parser = new CmdLineParser(options); try { parser.parseArgument(args); } catch(CmdLineException e) { System.err.println(e.getMessage()); System.err.println("Usage: java -jar LocalFeaturesTool.jar [-a] -i imageFile -o keypointFile"); parser.printUsage(System.err); return; } byte[] img = options.getInputImage(); LocalFeatureList<? extends LocalFeature<?>> kpl = options.getMode().getKeypointList(img); if (options.isAsciiMode()) { IOUtils.writeASCII(options.getOutput(), kpl); } else { IOUtils.writeBinary(options.getOutput(), kpl); } }  static void main(String [] args);  }
@Test public void testKeypointGeneration() throws IOException{ File tmpKeypointFile = folder.newFile("keypoint-testKeypointGeneration.key"); File tmpASCIIKeypointFile = folder.newFile("keypoint-testKeypointGeneration2.key"); String[] args = null; args = new String[]{ "-i",tmpImageFile.getAbsolutePath(), "-o",tmpKeypointFile.getAbsolutePath() }; LocalFeaturesTool.main(args); args = new String[]{ "-a", "-i",tmpImageFile.getAbsolutePath(), "-o",tmpASCIIKeypointFile.getAbsolutePath() }; LocalFeaturesTool.main(args); List<Keypoint> binary = MemoryLocalFeatureList.read(tmpKeypointFile, Keypoint.class); List<Keypoint> ascii = MemoryLocalFeatureList.read(tmpASCIIKeypointFile, Keypoint.class); for(int i = 0; i<binary.size();i++){ assertTrue(Arrays.equals(binary.get(i).ivec,ascii.get(i).ivec)); } }
@Test public void testKeypointImageTransform() throws IOException { File tmpKeypointFile = folder.newFile("keypoint-testKeypointImageTransform.key"); File tmpResizedKeypointFile = folder.newFile("keypointResized-testKeypointImageTransform.key"); tmpResizedKeypointFile.delete(); String[] args = null; args = new String[]{ "-i",tmpImageFile.getAbsolutePath(), "-o",tmpKeypointFile.getAbsolutePath() }; LocalFeaturesTool.main(args); args = new String[]{ "-i",tmpImageFile.getAbsolutePath(), "-o",tmpResizedKeypointFile.getAbsolutePath(), "-a", "-m","SIFT", "-it","RESIZE_MAX", "-dmax","1024" }; LocalFeaturesTool.main(args); assertTrue(tmpResizedKeypointFile.exists()); @SuppressWarnings("unused") List<Keypoint> resizedKeypoints = MemoryLocalFeatureList.read(tmpResizedKeypointFile, Keypoint.class); @SuppressWarnings("unused") List<Keypoint> normalKeypoints = MemoryLocalFeatureList.read(tmpResizedKeypointFile, Keypoint.class); @SuppressWarnings("unused") boolean set = false; @SuppressWarnings("unused") int resizedMinX, resizedMaxX,resizedMinY,resizedMaxY; @SuppressWarnings("unused") int normalMinX, normalMaxX,normalMinY,normalMaxY; }