Skip to content

Commit

Permalink
Don't calculate common_tracks for images that have been reconstructed
Browse files Browse the repository at this point in the history
  • Loading branch information
Brook Roberts committed Jun 21, 2017
1 parent c272fcb commit 84bcad1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 8 additions & 1 deletion opensfm/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,22 @@ def common_tracks(g, im1, im2):
return tracks, p1, p2


def all_common_tracks(graph, tracks, include_features=True, min_common=50):
def all_common_tracks(graph, tracks, include_features=True, min_common=50, remaining_images=None):
"""
Returns a dictionary mapping image pairs to the list of tracks observed in both images
:param graph: Graph structure (networkx) as returned by :method:`DataSet.tracks_graph`
:param tracks: list of track identifiers
:param include_features: whether to include the features from the images
:param min_common: the minimum number of tracks the two images need to have in common
:param remaining_images: if not none, only find pairs from within this list
:return: tuple: im1, im2 -> tuple: tracks, features from first image, features from second image
"""
if remaining_images is not None:
# We just look at the subgraph comprising of remaining images, and tracks that pass through them
tracks = {track for imagename in remaining_images for track in graph[imagename]}
filtered_nodes = set(remaining_images).union(tracks)
graph = graph.subgraph(filtered_nodes)

track_dict = defaultdict(list)
for tr in tracks:
track_images = sorted(graph[tr].keys())
Expand Down
6 changes: 5 additions & 1 deletion opensfm/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,11 @@ def incremental_reconstruction(data):
key=lambda x: -len(x.shots))
data.save_reconstruction(reconstructions)

common_tracks = matching.all_common_tracks(graph, tracks)
if len(reconstructed_images) != 0:
common_tracks = matching.all_common_tracks(graph, tracks, remaining_images=remaining_images)
else:
# Filtering the graph is slow, so don't pass remaining_images if all images are remaining
common_tracks = matching.all_common_tracks(graph, tracks)
pairs = compute_image_pairs(common_tracks, data.config)
for im1, im2 in pairs:
if im1 in remaining_images and im2 in remaining_images:
Expand Down

0 comments on commit 84bcad1

Please sign in to comment.