From 16c2007e197d2848bc2deb576141d213159d03f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= <124616582+f-dy@users.noreply.github.com> Date: Fri, 14 Mar 2025 21:16:26 +0100 Subject: [PATCH 1/2] colmap_dataparser: colmap's k4 parameter is valid for fisheye model fixes https://github.com/nerfstudio-project/nerfstudio/issues/3611 --- nerfstudio/data/dataparsers/colmap_dataparser.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/nerfstudio/data/dataparsers/colmap_dataparser.py b/nerfstudio/data/dataparsers/colmap_dataparser.py index 837794ce18..10c1938afa 100644 --- a/nerfstudio/data/dataparsers/colmap_dataparser.py +++ b/nerfstudio/data/dataparsers/colmap_dataparser.py @@ -28,7 +28,7 @@ from rich.prompt import Confirm from nerfstudio.cameras import camera_utils -from nerfstudio.cameras.cameras import CAMERA_MODEL_TO_TYPE, Cameras +from nerfstudio.cameras.cameras import CAMERA_MODEL_TO_TYPE, Cameras, CameraType from nerfstudio.data.dataparsers.base_dataparser import DataParser, DataParserConfig, DataparserOutputs from nerfstudio.data.scene_box import SceneBox from nerfstudio.data.utils import colmap_parsing_utils as colmap_utils @@ -276,12 +276,14 @@ def _generate_dataparser_outputs(self, split: str = "train", **kwargs): cy.append(float(frame["cy"])) height.append(int(frame["h"])) width.append(int(frame["w"])) - if any([k in frame and float(frame[k]) != 0.0 for k in ["k4", "k5", "k6"]]): + if float(frame["k4"]) != 0.0 and camera_type == CameraType.PERSPECTIVE: raise ValueError( - "K4/K5/K6 is non-zero! Note that Nerfstudio camera model's K4 has different meaning than colmap " - "OPENCV camera model K4. Nerfstudio's K4 is the 4-th order of radial distortion coefficient, while " - "colmap/OPENCV's K4 is 4-th coefficient in fractional radial distortion model." + "K4 is non-zero! Note that Nerfstudio's perspective distortion parameter K4 has different meaning " + "than colmap's OPENCV parameter K4. Nerfstudio's K4 is the 4-th order of radial distortion " + "coefficient, while colmap/OPENCV's K4 is 4-th coefficient in fractional radial distortion model." ) + if any([k in frame and float(frame[k]) != 0.0 for k in ["k5", "k6"]]): + raise ValueError("Non-zero K5 or K6 distortion parameter is unsupported by Nerfstudio .") distort.append( camera_utils.get_distortion_params( k1=float(frame["k1"]) if "k1" in frame else 0.0, From dc63b9882cbe1ec6b9ca3a6d4f20af5bfab28483 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= <124616582+f-dy@users.noreply.github.com> Date: Fri, 14 Mar 2025 21:32:08 +0100 Subject: [PATCH 2/2] Update colmap_dataparser.py --- nerfstudio/data/dataparsers/colmap_dataparser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nerfstudio/data/dataparsers/colmap_dataparser.py b/nerfstudio/data/dataparsers/colmap_dataparser.py index 10c1938afa..69a862e7f1 100644 --- a/nerfstudio/data/dataparsers/colmap_dataparser.py +++ b/nerfstudio/data/dataparsers/colmap_dataparser.py @@ -276,7 +276,7 @@ def _generate_dataparser_outputs(self, split: str = "train", **kwargs): cy.append(float(frame["cy"])) height.append(int(frame["h"])) width.append(int(frame["w"])) - if float(frame["k4"]) != 0.0 and camera_type == CameraType.PERSPECTIVE: + if camera_type == CameraType.PERSPECTIVE and "k4" in frame and float(frame["k4"]) != 0.0: raise ValueError( "K4 is non-zero! Note that Nerfstudio's perspective distortion parameter K4 has different meaning " "than colmap's OPENCV parameter K4. Nerfstudio's K4 is the 4-th order of radial distortion "