Skip to content

Commit a0671c4

Browse files
committed
Ignore matching_gps_neighbors if any image has no GPS data
1 parent d3c7528 commit a0671c4

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

bin/match_features

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
#!/usr/bin/env python
22
import os.path, sys
3-
import time
43
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
54

5+
import argparse
6+
import logging
67
from multiprocessing import Pool
8+
import time
9+
710
import numpy as np
8-
from itertools import combinations
9-
import argparse
11+
1012
from opensfm import dataset
11-
from opensfm import features
1213
from opensfm import matching
1314
from opensfm import geo
1415

16+
logger = logging.getLogger(__name__)
17+
1518

1619
def has_gps_info(exif):
1720
return (exif
@@ -26,7 +29,7 @@ def distance_from_exif(exif1, exif2):
2629
gps2 = exif2['gps']
2730
lon1, lat1 = gps1['longitude'], gps1['latitude']
2831
lon2, lat2 = gps2['longitude'], gps2['latitude']
29-
return geo.gps_distance([lon1,lat1], [lon2, lat2])
32+
return geo.gps_distance([lon1, lat1], [lon2, lat2])
3033
else:
3134
return 0
3235

@@ -42,6 +45,11 @@ def match_candidates_from_metadata(images, exifs, data):
4245
max_neighbors = data.config['matching_gps_neighbors']
4346
max_time_neighbors = data.config['matching_time_neighbors']
4447

48+
if not all(map(has_gps_info, exifs)) and max_neighbors != 0:
49+
logger.warn("Not all images have GPS info. "
50+
"Disabling matching_gps_neighbors.")
51+
max_neighbors = 0
52+
4553
pairs = set()
4654
for im1 in images:
4755
distances = []
@@ -135,6 +143,7 @@ def match_arguments(pairs):
135143

136144

137145
if __name__ == "__main__":
146+
logging.basicConfig(level=logging.DEBUG)
138147
parser = argparse.ArgumentParser(description='Match features between all image pairs.')
139148
parser.add_argument('dataset', help='path to the dataset to be processed')
140149
args = parser.parse_args()

0 commit comments

Comments
 (0)