@Test public void testConsensusSetsRun() throws Exception { testDirectory = MipmapClientTest.createTestDirectory("ransac_filter_test_consensus"); final File candidateFile = new File(testDirectory, "candidate_matches.json"); Files.write(candidateFile.toPath(), CANDIDATE_MATCHES.getBytes()); final String argString = "--matchRod 0.5 --matchModelType AFFINE --matchIterations 1000 --matchMaxEpsilon 2.0 --matchMinInlierRatio 0.0 " + "--matchMaxTrust 1.0 --matchFilter CONSENSUS_SETS " + "--candidateFile \"" + candidateFile.getAbsolutePath() + "\" " + "--outputDirectory \"" + testDirectory.getAbsolutePath() + "\""; final RansacFilterClient.Parameters clientParameters = new RansacFilterClient.Parameters(); clientParameters.parse(argString.split(" ")); final RansacFilterClient client = new RansacFilterClient(clientParameters); client.run(); validateResults(new int[] { 109, 30, 26, 18, 8, 7, 5, 70, 20, 9, 8, 5, 109, 51, 36, 33, 27, 14, 13, 9, 8, 7, 6, 5, 4 }); }
public void run() throws Exception { final CanvasFeatureMatcher matcher = new CanvasFeatureMatcher(parameters.matchDerivation); final List<CanvasMatches> inlierCanvasMatchesLists = new ArrayList<>(); for (final CanvasMatches pair : loadMatchData(parameters.candidateFile)) { final Model model = matcher.getModel(); final List<PointMatch> candidates = new ArrayList<>( CanvasFeatureMatchResult.convertMatchesToPointMatchList(pair.getMatches())); List<List<PointMatch>> inliersLists = new ArrayList<>(); switch (parameters.matchDerivation.matchFilter) { case SINGLE_SET: inliersLists = Collections.singletonList(matcher.filterMatches(candidates, model)); break; case CONSENSUS_SETS: inliersLists = matcher.filterConsensusMatches(candidates); break; case NONE: throw new IllegalArgumentException("--matchFilter indicates no filtering needed"); } final int numberOfConsensusSets = inliersLists.size(); for (int i = 0; i < numberOfConsensusSets; i++) { final CanvasMatches filteredCanvasMatches; if (numberOfConsensusSets > 1) { final String setSuffix = String.format("_set_%03d", i); filteredCanvasMatches = new CanvasMatches(pair.getpGroupId(), pair.getpId() + setSuffix, pair.getqGroupId(), pair.getqId() + setSuffix, CanvasFeatureMatchResult.convertPointMatchListToMatches(inliersLists.get(i), 1.0)); filteredCanvasMatches.setConsensusSetData(new ConsensusSetData(i, pair.getpId(), pair.getqId())); } else { filteredCanvasMatches = new CanvasMatches(pair.getpGroupId(), pair.getpId(), pair.getqGroupId(), pair.getqId(), CanvasFeatureMatchResult.convertPointMatchListToMatches(inliersLists.get(i), 1.0)); } inlierCanvasMatchesLists.add(filteredCanvasMatches); } } final String[] sourceFileNameElements = splitFileName(parameters.candidateFile); final String baseName = sourceFileNameElements[0] + "_filtered"; final String extension = sourceFileNameElements[1]; final Path outputFilePath = Paths.get(parameters.outputDirectory, baseName + extension).toAbsolutePath(); saveMatchData(inlierCanvasMatchesLists, outputFilePath.toString()); }
RansacFilterClient { public void run() throws Exception { final CanvasFeatureMatcher matcher = new CanvasFeatureMatcher(parameters.matchDerivation); final List<CanvasMatches> inlierCanvasMatchesLists = new ArrayList<>(); for (final CanvasMatches pair : loadMatchData(parameters.candidateFile)) { final Model model = matcher.getModel(); final List<PointMatch> candidates = new ArrayList<>( CanvasFeatureMatchResult.convertMatchesToPointMatchList(pair.getMatches())); List<List<PointMatch>> inliersLists = new ArrayList<>(); switch (parameters.matchDerivation.matchFilter) { case SINGLE_SET: inliersLists = Collections.singletonList(matcher.filterMatches(candidates, model)); break; case CONSENSUS_SETS: inliersLists = matcher.filterConsensusMatches(candidates); break; case NONE: throw new IllegalArgumentException("--matchFilter indicates no filtering needed"); } final int numberOfConsensusSets = inliersLists.size(); for (int i = 0; i < numberOfConsensusSets; i++) { final CanvasMatches filteredCanvasMatches; if (numberOfConsensusSets > 1) { final String setSuffix = String.format("_set_%03d", i); filteredCanvasMatches = new CanvasMatches(pair.getpGroupId(), pair.getpId() + setSuffix, pair.getqGroupId(), pair.getqId() + setSuffix, CanvasFeatureMatchResult.convertPointMatchListToMatches(inliersLists.get(i), 1.0)); filteredCanvasMatches.setConsensusSetData(new ConsensusSetData(i, pair.getpId(), pair.getqId())); } else { filteredCanvasMatches = new CanvasMatches(pair.getpGroupId(), pair.getpId(), pair.getqGroupId(), pair.getqId(), CanvasFeatureMatchResult.convertPointMatchListToMatches(inliersLists.get(i), 1.0)); } inlierCanvasMatchesLists.add(filteredCanvasMatches); } } final String[] sourceFileNameElements = splitFileName(parameters.candidateFile); final String baseName = sourceFileNameElements[0] + "_filtered"; final String extension = sourceFileNameElements[1]; final Path outputFilePath = Paths.get(parameters.outputDirectory, baseName + extension).toAbsolutePath(); saveMatchData(inlierCanvasMatchesLists, outputFilePath.toString()); } }
RansacFilterClient { public void run() throws Exception { final CanvasFeatureMatcher matcher = new CanvasFeatureMatcher(parameters.matchDerivation); final List<CanvasMatches> inlierCanvasMatchesLists = new ArrayList<>(); for (final CanvasMatches pair : loadMatchData(parameters.candidateFile)) { final Model model = matcher.getModel(); final List<PointMatch> candidates = new ArrayList<>( CanvasFeatureMatchResult.convertMatchesToPointMatchList(pair.getMatches())); List<List<PointMatch>> inliersLists = new ArrayList<>(); switch (parameters.matchDerivation.matchFilter) { case SINGLE_SET: inliersLists = Collections.singletonList(matcher.filterMatches(candidates, model)); break; case CONSENSUS_SETS: inliersLists = matcher.filterConsensusMatches(candidates); break; case NONE: throw new IllegalArgumentException("--matchFilter indicates no filtering needed"); } final int numberOfConsensusSets = inliersLists.size(); for (int i = 0; i < numberOfConsensusSets; i++) { final CanvasMatches filteredCanvasMatches; if (numberOfConsensusSets > 1) { final String setSuffix = String.format("_set_%03d", i); filteredCanvasMatches = new CanvasMatches(pair.getpGroupId(), pair.getpId() + setSuffix, pair.getqGroupId(), pair.getqId() + setSuffix, CanvasFeatureMatchResult.convertPointMatchListToMatches(inliersLists.get(i), 1.0)); filteredCanvasMatches.setConsensusSetData(new ConsensusSetData(i, pair.getpId(), pair.getqId())); } else { filteredCanvasMatches = new CanvasMatches(pair.getpGroupId(), pair.getpId(), pair.getqGroupId(), pair.getqId(), CanvasFeatureMatchResult.convertPointMatchListToMatches(inliersLists.get(i), 1.0)); } inlierCanvasMatchesLists.add(filteredCanvasMatches); } } final String[] sourceFileNameElements = splitFileName(parameters.candidateFile); final String baseName = sourceFileNameElements[0] + "_filtered"; final String extension = sourceFileNameElements[1]; final Path outputFilePath = Paths.get(parameters.outputDirectory, baseName + extension).toAbsolutePath(); saveMatchData(inlierCanvasMatchesLists, outputFilePath.toString()); } RansacFilterClient(final Parameters parameters); }
RansacFilterClient { public void run() throws Exception { final CanvasFeatureMatcher matcher = new CanvasFeatureMatcher(parameters.matchDerivation); final List<CanvasMatches> inlierCanvasMatchesLists = new ArrayList<>(); for (final CanvasMatches pair : loadMatchData(parameters.candidateFile)) { final Model model = matcher.getModel(); final List<PointMatch> candidates = new ArrayList<>( CanvasFeatureMatchResult.convertMatchesToPointMatchList(pair.getMatches())); List<List<PointMatch>> inliersLists = new ArrayList<>(); switch (parameters.matchDerivation.matchFilter) { case SINGLE_SET: inliersLists = Collections.singletonList(matcher.filterMatches(candidates, model)); break; case CONSENSUS_SETS: inliersLists = matcher.filterConsensusMatches(candidates); break; case NONE: throw new IllegalArgumentException("--matchFilter indicates no filtering needed"); } final int numberOfConsensusSets = inliersLists.size(); for (int i = 0; i < numberOfConsensusSets; i++) { final CanvasMatches filteredCanvasMatches; if (numberOfConsensusSets > 1) { final String setSuffix = String.format("_set_%03d", i); filteredCanvasMatches = new CanvasMatches(pair.getpGroupId(), pair.getpId() + setSuffix, pair.getqGroupId(), pair.getqId() + setSuffix, CanvasFeatureMatchResult.convertPointMatchListToMatches(inliersLists.get(i), 1.0)); filteredCanvasMatches.setConsensusSetData(new ConsensusSetData(i, pair.getpId(), pair.getqId())); } else { filteredCanvasMatches = new CanvasMatches(pair.getpGroupId(), pair.getpId(), pair.getqGroupId(), pair.getqId(), CanvasFeatureMatchResult.convertPointMatchListToMatches(inliersLists.get(i), 1.0)); } inlierCanvasMatchesLists.add(filteredCanvasMatches); } } final String[] sourceFileNameElements = splitFileName(parameters.candidateFile); final String baseName = sourceFileNameElements[0] + "_filtered"; final String extension = sourceFileNameElements[1]; final Path outputFilePath = Paths.get(parameters.outputDirectory, baseName + extension).toAbsolutePath(); saveMatchData(inlierCanvasMatchesLists, outputFilePath.toString()); } RansacFilterClient(final Parameters parameters); static void main(final String[] args); void run(); }
RansacFilterClient { public void run() throws Exception { final CanvasFeatureMatcher matcher = new CanvasFeatureMatcher(parameters.matchDerivation); final List<CanvasMatches> inlierCanvasMatchesLists = new ArrayList<>(); for (final CanvasMatches pair : loadMatchData(parameters.candidateFile)) { final Model model = matcher.getModel(); final List<PointMatch> candidates = new ArrayList<>( CanvasFeatureMatchResult.convertMatchesToPointMatchList(pair.getMatches())); List<List<PointMatch>> inliersLists = new ArrayList<>(); switch (parameters.matchDerivation.matchFilter) { case SINGLE_SET: inliersLists = Collections.singletonList(matcher.filterMatches(candidates, model)); break; case CONSENSUS_SETS: inliersLists = matcher.filterConsensusMatches(candidates); break; case NONE: throw new IllegalArgumentException("--matchFilter indicates no filtering needed"); } final int numberOfConsensusSets = inliersLists.size(); for (int i = 0; i < numberOfConsensusSets; i++) { final CanvasMatches filteredCanvasMatches; if (numberOfConsensusSets > 1) { final String setSuffix = String.format("_set_%03d", i); filteredCanvasMatches = new CanvasMatches(pair.getpGroupId(), pair.getpId() + setSuffix, pair.getqGroupId(), pair.getqId() + setSuffix, CanvasFeatureMatchResult.convertPointMatchListToMatches(inliersLists.get(i), 1.0)); filteredCanvasMatches.setConsensusSetData(new ConsensusSetData(i, pair.getpId(), pair.getqId())); } else { filteredCanvasMatches = new CanvasMatches(pair.getpGroupId(), pair.getpId(), pair.getqGroupId(), pair.getqId(), CanvasFeatureMatchResult.convertPointMatchListToMatches(inliersLists.get(i), 1.0)); } inlierCanvasMatchesLists.add(filteredCanvasMatches); } } final String[] sourceFileNameElements = splitFileName(parameters.candidateFile); final String baseName = sourceFileNameElements[0] + "_filtered"; final String extension = sourceFileNameElements[1]; final Path outputFilePath = Paths.get(parameters.outputDirectory, baseName + extension).toAbsolutePath(); saveMatchData(inlierCanvasMatchesLists, outputFilePath.toString()); } RansacFilterClient(final Parameters parameters); static void main(final String[] args); void run();  }