mapillary / OpenSfM

Open source Structure-from-Motion pipeline
https://www.opensfm.org/
BSD 2-Clause "Simplified" License
3.35k stars 852 forks source link

Descriptors of the final 3D points #170

Closed fouadAmer closed 7 years ago

fouadAmer commented 7 years ago

Hey. I am wondering if there is a way to export the descriptors that are associated only with the final reconstructed 3D points ? I know the saved descriptors are associated with all the features extracted from every image, but since not every feature ends up being a 3D point, finding the index of the descriptor of a specific 3D point is not clear. What i exactly need is a way to associate every reconstructed 3D point with its descriptor. Thanks a lot !

paulinus commented 7 years ago

hi @fouadAmer here is a set of examples that you can combine to do what you need

from opensfm import dataset

# Load the berlin dataset
data = dataset.DataSet('data/berlin')

# Load correspondences graph
graph = data.load_tracks_graph()

# Tracks associated with `01.jpg`
print graph['01.jpg']

# Observations of track `2`
print graph['2']

# Observation of track `2` in image `01.jpg`
# (if track `2` is not observed in image `01.jpg` try another track)
print graph['2']['01.jpg']
print graph['01.jpg']['2']

# Load the reconstruction
r = data.load_reconstruction()

# List reconstructed points, coordinates and observations
# Note that point ids are the same as track ids
for point in r[0].points.values():
    print point.id, point.coordinates, graph[point.id]

# Load features of `01.jpg`
points, descriptors, colors = data.load_features('01.jpg')

# descriptor of the observation of track `2` in image `01.jpg`
descriptors[graph['2']['01.jpg']['feature_id']]
fouadAmer commented 7 years ago

Thank you!