MCPcopy Create free account
hub / github.com/colmap/colmap / process_dataset

Function process_dataset

python/ci/test_regression_eth3d.py:71–172  ·  view source on GitHub ↗
(args: argparse.Namespace, dataset_name: str)

Source from the content-addressed store, hash-verified

69
70
71def process_dataset(args: argparse.Namespace, dataset_name: str) -> None:
72 logging.info("Processing dataset:", dataset_name)
73
74 workspace_path = os.path.join(
75 os.path.realpath(args.workspace_path), dataset_name
76 )
77 os.makedirs(workspace_path, exist_ok=True)
78
79 dataset_archive_path = os.path.join(workspace_path, f"{dataset_name}.7z")
80 download_file(
81 f"https://www.eth3d.net/data/{dataset_name}_dslr_undistorted.7z",
82 dataset_archive_path,
83 )
84
85 subprocess.check_call(
86 ["7zz", "x", "-y", f"{dataset_name}.7z"], cwd=workspace_path
87 )
88
89 # Find undistorted parameters of first camera and
90 # initialize all images with it. This is an approximation
91 # because not all datasets have only a single camera.
92 # However, it is a good enough initialization.
93 with open(
94 os.path.join(
95 workspace_path,
96 f"{dataset_name}/dslr_calibration_undistorted/cameras.txt",
97 ),
98 ) as fid:
99 for line in fid:
100 if not line.startswith("#"):
101 first_camera_data = line.split()
102 camera_model = first_camera_data[1]
103 assert camera_model == "PINHOLE"
104 camera_params = first_camera_data[4:]
105 assert len(camera_params) == 4
106 break
107
108 # Count the number of expected images in the GT.
109 expected_num_images = 0
110 with open(
111 os.path.join(
112 workspace_path,
113 f"{dataset_name}/dslr_calibration_undistorted/images.txt",
114 ),
115 ) as fid:
116 for line in fid:
117 if not line.startswith("#") and line.strip():
118 expected_num_images += 1
119 # Each image uses two consecutive lines.
120 assert expected_num_images % 2 == 0
121 expected_num_images //= 2
122
123 # Run automatic reconstruction pipeline.
124 subprocess.check_call(
125 [
126 os.path.realpath(args.colmap_path),
127 "automatic_reconstructor",
128 "--image_path",

Callers 1

mainFunction · 0.85

Calls 2

download_fileFunction · 0.70

Tested by

no test coverage detected