mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 14:58:55 +08:00
Improve windows support (#374)
This commit is contained in:
1 parent
e7cca834c8
commit
3ae6502116
1 file changed
+8
-7
@@ -168,10 +168,11 @@ def downscale_images(image_dir: Path, num_downscales: int, verbose: bool = False
|
|||||||
downscale_dir = image_dir.parent / f"images_{downscale_factor}"
|
downscale_dir = image_dir.parent / f"images_{downscale_factor}"
|
||||||
downscale_dir.mkdir(parents=True, exist_ok=True)
|
downscale_dir.mkdir(parents=True, exist_ok=True)
|
||||||
file_type = image_dir.glob("frame_*").__next__().suffix
|
file_type = image_dir.glob("frame_*").__next__().suffix
|
||||||
|
filename = f"frame_%05d{file_type}"
|
||||||
ffmpeg_cmd = [
|
ffmpeg_cmd = [
|
||||||
f"ffmpeg -i {image_dir}/frame_%05d{file_type} ",
|
f"ffmpeg -i {image_dir / filename} ",
|
||||||
f"-vf scale=iw/{downscale_factor}:ih/{downscale_factor} ",
|
f"-vf scale=iw/{downscale_factor}:ih/{downscale_factor} ",
|
||||||
f"{downscale_dir}/frame_%05d{file_type}",
|
f"{downscale_dir / filename}",
|
||||||
]
|
]
|
||||||
ffmpeg_cmd = " ".join(ffmpeg_cmd)
|
ffmpeg_cmd = " ".join(ffmpeg_cmd)
|
||||||
run_command(ffmpeg_cmd, verbose=verbose)
|
run_command(ffmpeg_cmd, verbose=verbose)
|
||||||
@@ -201,7 +202,7 @@ def run_colmap(
|
|||||||
# Feature extraction
|
# Feature extraction
|
||||||
feature_extractor_cmd = [
|
feature_extractor_cmd = [
|
||||||
"colmap feature_extractor",
|
"colmap feature_extractor",
|
||||||
f"--database_path {colmap_dir}/database.db",
|
f"--database_path {colmap_dir / 'database.db'}",
|
||||||
f"--image_path {image_dir}",
|
f"--image_path {image_dir}",
|
||||||
"--ImageReader.single_camera 1",
|
"--ImageReader.single_camera 1",
|
||||||
f"--ImageReader.camera_model {camera_model.value}",
|
f"--ImageReader.camera_model {camera_model.value}",
|
||||||
@@ -218,7 +219,7 @@ def run_colmap(
|
|||||||
# Feature matching
|
# Feature matching
|
||||||
feature_matcher_cmd = [
|
feature_matcher_cmd = [
|
||||||
"colmap exhaustive_matcher",
|
"colmap exhaustive_matcher",
|
||||||
f"--database_path {colmap_dir}/database.db",
|
f"--database_path {colmap_dir / 'database.db'}",
|
||||||
f"--SiftMatching.use_gpu {int(gpu)}",
|
f"--SiftMatching.use_gpu {int(gpu)}",
|
||||||
]
|
]
|
||||||
feature_matcher_cmd = " ".join(feature_matcher_cmd)
|
feature_matcher_cmd = " ".join(feature_matcher_cmd)
|
||||||
@@ -234,7 +235,7 @@ def run_colmap(
|
|||||||
sparse_dir.mkdir(parents=True, exist_ok=True)
|
sparse_dir.mkdir(parents=True, exist_ok=True)
|
||||||
bundle_adjuster_cmd = [
|
bundle_adjuster_cmd = [
|
||||||
"colmap mapper",
|
"colmap mapper",
|
||||||
f"--database_path {colmap_dir}/database.db",
|
f"--database_path {colmap_dir / 'database.db'}",
|
||||||
f"--image_path {image_dir}",
|
f"--image_path {image_dir}",
|
||||||
f"--output_path {sparse_dir}",
|
f"--output_path {sparse_dir}",
|
||||||
]
|
]
|
||||||
@@ -284,10 +285,10 @@ def colmap_to_json(cameras_path: Path, images_path: Path, output_dir: Path, came
|
|||||||
c2w = c2w[np.array([1, 0, 2, 3]), :]
|
c2w = c2w[np.array([1, 0, 2, 3]), :]
|
||||||
c2w[2, :] *= -1
|
c2w[2, :] *= -1
|
||||||
|
|
||||||
name = f"./images/{im_data.name}"
|
name = Path(f"./images/{im_data.name}")
|
||||||
|
|
||||||
frame = {
|
frame = {
|
||||||
"file_path": name,
|
"file_path": str(name),
|
||||||
"transform_matrix": c2w.tolist(),
|
"transform_matrix": c2w.tolist(),
|
||||||
}
|
}
|
||||||
frames.append(frame)
|
frames.append(frame)
|
||||||
|
|||||||
Reference in new issue
Block a user