From a0671c43fc004f0a82f6b2c1805ee6a39dd3c109 Mon Sep 17 00:00:00 2001 From: Pau Gargallo Date: Mon, 21 Dec 2015 23:53:32 +0100 Subject: [PATCH] Ignore matching_gps_neighbors if any image has no GPS data --- bin/match_features | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/bin/match_features b/bin/match_features index b581c43ca..cd9487128 100755 --- a/bin/match_features +++ b/bin/match_features @@ -1,17 +1,20 @@ #!/usr/bin/env python import os.path, sys -import time sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) +import argparse +import logging from multiprocessing import Pool +import time + import numpy as np -from itertools import combinations -import argparse + from opensfm import dataset -from opensfm import features from opensfm import matching from opensfm import geo +logger = logging.getLogger(__name__) + def has_gps_info(exif): return (exif @@ -26,7 +29,7 @@ def distance_from_exif(exif1, exif2): gps2 = exif2['gps'] lon1, lat1 = gps1['longitude'], gps1['latitude'] lon2, lat2 = gps2['longitude'], gps2['latitude'] - return geo.gps_distance([lon1,lat1], [lon2, lat2]) + return geo.gps_distance([lon1, lat1], [lon2, lat2]) else: return 0 @@ -42,6 +45,11 @@ def match_candidates_from_metadata(images, exifs, data): max_neighbors = data.config['matching_gps_neighbors'] max_time_neighbors = data.config['matching_time_neighbors'] + if not all(map(has_gps_info, exifs)) and max_neighbors != 0: + logger.warn("Not all images have GPS info. " + "Disabling matching_gps_neighbors.") + max_neighbors = 0 + pairs = set() for im1 in images: distances = [] @@ -135,6 +143,7 @@ def match_arguments(pairs): if __name__ == "__main__": + logging.basicConfig(level=logging.DEBUG) parser = argparse.ArgumentParser(description='Match features between all image pairs.') parser.add_argument('dataset', help='path to the dataset to be processed') args = parser.parse_args()