Skip to content

Instantly share code, notes, and snippets.

@cdcseacave
Created April 14, 2022 17:43
Show Gist options
  • Save cdcseacave/e5a5649da168a0140caf2ed077534651 to your computer and use it in GitHub Desktop.
Save cdcseacave/e5a5649da168a0140caf2ed077534651 to your computer and use it in GitHub Desktop.
Convert cameras_poses.log generated by InterfaceCOLMAP to individual poses files
import argh
import os
import numpy as np
def extract_colmap_poses(
log_file: str,
output_path: str,
) -> None:
print('Loading ', log_file)
lines = []
with open(log_file, 'r') as f:
lines = f.readlines()
if not os.path.exists(output_path):
os.mkdir(output_path)
for i in range(0,len(lines),5):
with open(os.path.join(output_path, '0_{:04d}.txt'.format(int(i/5))), 'w') as f:
for j in range(i+1, i+5):
f.write(lines[j])
if __name__ == "__main__":
argh.dispatch_command(extract_colmap_poses)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment