Skip to content

Instantly share code, notes, and snippets.

@sergeyprokudin
Created July 5, 2021 11:08
Show Gist options
  • Save sergeyprokudin/30b41f2020622586e7349fb64ee8cae8 to your computer and use it in GitHub Desktop.
Save sergeyprokudin/30b41f2020622586e7349fb64ee8cae8 to your computer and use it in GitHub Desktop.
import numpy as np
def load_colmap_sparse_points(points3d_path):
'''Load COLMAP points3D.txt as numpy array
'''
with open(points3d_path, 'r') as f:
points_txt = f.readlines()[3:]
n_points = len(points_txt)
points_np = np.zeros([n_points, 6])
for pid, point in enumerate(points_txt):
xyz = np.asarray(point.split(' ')[1:4], dtype='float')
rgb = np.asarray(point.split(' ')[4:7], dtype='int') / 255
points_np[pid, 0:3] = xyz
points_np[pid, 3:6] = rgb
return points_np
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment