def test_match_images(scene_synthetic): reference = scene_synthetic[0].get_reconstruction() synthetic = synthetic_dataset.SyntheticDataSet( reference, scene_synthetic[1], scene_synthetic[2], scene_synthetic[3], scene_synthetic[4], scene_synthetic[5], ) synthetic.matches_exists = lambda im: False synthetic.save_matches = lambda im, m: False override = {} override["matching_gps_neighbors"] = 0 override["matching_gps_distance"] = 0 override["matching_time_neighbors"] = 2 images = sorted(synthetic.images()) pairs, _ = matching.match_images(synthetic, override, images, images) matching.save_matches(synthetic, images, pairs) for i in range(len(images) - 1): pair = images[i], images[i + 1] matches = pairs.get(pair) if matches is None or len(matches) == 1: matches = pairs.get(pair[::-1]) assert len(matches) > 25
def run(self, args): data = dataset.DataSet(args.dataset) queryImages = None if (args.localize): localizeDir = os.path.join(args.dataset, "localize") print("Localization - creating matches: ") queryImages = [ x for x in os.listdir(localizeDir) if x.endswith(".jpg") ] [print(os.path.join(localizeDir, str(x))) for x in queryImages] else: queryImages = data.images() start = timer() pairs_matches, preport = matching.match_images( data, queryImages, data.images( )) #2nd Argument, ref_images will be those images that are query. matching.save_matches(data, queryImages, pairs_matches) end = timer() with open(data.profile_log(), 'a') as fout: fout.write('match_features: {0}\n'.format(end - start)) self.write_report(data, preport, list(pairs_matches.keys()), end - start)
def _(self): with attach_stub(matching, "match_images_with_pairs"): images = self.images pairs_matches, preport = matching.match_images( self.data, images, images) args, kwargs = last_call_of(matching.match_images_with_pairs) data, exifs, ref_images, pairs = args expect(pairs).to_be(self.expected_pairs)
def run_dataset(data: DataSetBase): """ Match features between image pairs. """ images = data.images() start = timer() pairs_matches, preport = matching.match_images(data, {}, images, images) matching.save_matches(data, images, pairs_matches) end = timer() write_report(data, preport, list(pairs_matches.keys()), end - start)
def run(self, args): data = dataset.DataSet(args.dataset) images = data.images() start = timer() pairs_matches, preport = matching.match_images(data, images, images) end = timer() with open(data.profile_log(), 'a') as fout: fout.write('match_features: {0}\n'.format(end - start)) self.write_report(data, preport, list(pairs_matches.keys()), end - start)
def run(data): images = [] for i in data.images(): images.append(i) start = timer() pairs_matches, preport = matching.match_images(data, images, images) save_matches(data, images, pairs_matches) end = timer() with open(data.profile_log(), 'a') as fout: fout.write('match_features: {0}\n'.format(end - start)) write_report(data, preport, list(pairs_matches.keys()), end - start)
def test_match_images(scene_synthetic): reference = scene_synthetic[0].get_reconstruction() synthetic = synthetic_dataset.SyntheticDataSet( reference, scene_synthetic[1], scene_synthetic[2], scene_synthetic[3], scene_synthetic[4], scene_synthetic[5]) synthetic.matches_exists = lambda im: False synthetic.save_matches = lambda im, m: False num_neighbors = 5 synthetic.config['matching_gps_neighbors'] = num_neighbors synthetic.config['bow_words_to_match'] = 8 synthetic.config['matcher_type'] = 'FLANN' images = synthetic.images() pairs, _ = matching.match_images(synthetic, images, images, True) assert len(pairs) == 62 value, margin = 11842, 0.01 assert value * (1 - margin) < sum([len(m) for m in pairs.values() ]) < value * (1 + margin)
def test_match_images(scene_synthetic) -> None: reference = scene_synthetic.reconstruction synthetic = synthetic_dataset.SyntheticDataSet( reference, scene_synthetic.exifs, scene_synthetic.features, scene_synthetic.tracks_manager, ) # pyre-fixme[8]: Attribute has type # `BoundMethod[typing.Callable(SyntheticDataSet.matches_exists)[[Named(self, # SyntheticDataSet), Named(image, str)], bool], SyntheticDataSet]`; used as `(im: # Any) -> bool`. synthetic.matches_exists = lambda im: False # pyre-fixme[8]: Attribute has type # `BoundMethod[typing.Callable(DataSet.save_matches)[[Named(self, DataSet), # Named(image, str), Named(matches, Dict[str, ndarray])], None], # SyntheticDataSet]`; used as `(im: Any, m: Any) -> bool`. synthetic.save_matches = lambda im, m: False override = {} override["matching_gps_neighbors"] = 0 override["matching_gps_distance"] = 0 override["matching_time_neighbors"] = 2 images = sorted(synthetic.images()) pairs, _ = matching.match_images(synthetic, override, images, images) matching.save_matches(synthetic, images, pairs) for i in range(len(images) - 1): pair = images[i], images[i + 1] matches = pairs.get(pair) if matches is None or len(matches) == 1: matches = pairs.get(pair[::-1]) # pyre-fixme[6]: For 1st param expected `Sized` but got # `Optional[List[Tuple[int, int]]]`. assert len(matches) > 25