MCPcopy Create free account
hub / github.com/dcharatan/flowmap / run_dense

Function run_dense

scripts/colmap/run_dense.py:10–57  ·  view source on GitHub ↗
(input_path: Path, output_path: Path)

Source from the content-addressed store, hash-verified

8
9
10def run_dense(input_path: Path, output_path: Path) -> None:
11 if (input_path / "sparse/1").exists():
12 raise FileExistsError(
13 "Make sure only a single sparse model exists! If there's more than one "
14 "model, sparse reconstruction failed."
15 )
16
17 # Copy the input path to the output path.
18 shutil.copytree(input_path, output_path)
19
20 start_time = time()
21
22 # Run the dense reconstruction commands.
23 command = (
24 "colmap image_undistorter",
25 f"--image_path {output_path}/images",
26 f"--input_path {output_path}/sparse/0",
27 f"--output_path {output_path}/dense",
28 "--output_type COLMAP",
29 )
30 if subprocess.run(" ".join(command).split(" ")).returncode != 0:
31 raise Exception("COLMAP dense reconstruction failed.")
32
33 command = (
34 "colmap patch_match_stereo",
35 f"--workspace_path {output_path}/dense",
36 "--workspace_format COLMAP",
37 "--PatchMatchStereo.geom_consistency true",
38 )
39 if subprocess.run(" ".join(command).split(" ")).returncode != 0:
40 raise Exception("COLMAP dense reconstruction failed.")
41
42 command = (
43 "colmap stereo_fusion",
44 f"--workspace_path {output_path}/dense",
45 "--workspace_format COLMAP",
46 "--input_type geometric",
47 f"--output_path {output_path}/dense/fused.ply",
48 )
49 if subprocess.run(" ".join(command).split(" ")).returncode != 0:
50 raise Exception("COLMAP dense reconstruction failed.")
51
52 # Copy the dense point cloud to the right location for 3D Gaussian Splatting.
53 shutil.copy(output_path / "dense/fused.ply", output_path / "sparse/0/points3D.ply")
54
55 elapsed = time() - start_time
56 with (output_path / "runtime.json").open("w") as f:
57 json.dump({"runtime": elapsed}, f)
58
59
60@click.command()

Callers 2

mainFunction · 0.90
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected