mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-01 13:28:59 +08:00
Add fisheye support to data processing (#369)
add fisheye support to data processing
This commit is contained in:
1 parent
7b6ed5496b
commit
e319b8210a
3 files changed
+67
-18
No files matched your search
@@ -36,6 +36,16 @@ class CameraType(Enum):
|
||||
FISHEYE = auto()
|
||||
|
||||
|
||||
CAMERA_MODEL_TO_TYPE = {
|
||||
"SIMPLE_PINHOLE": CameraType.PERSPECTIVE,
|
||||
"PINHOLE": CameraType.PERSPECTIVE,
|
||||
"SIMPLE_RADIAL": CameraType.PERSPECTIVE,
|
||||
"RADIAL": CameraType.PERSPECTIVE,
|
||||
"OPENCV": CameraType.PERSPECTIVE,
|
||||
"OPENCV_FISHEYE": CameraType.FISHEYE,
|
||||
}
|
||||
|
||||
|
||||
class Cameras:
|
||||
"""Dataset inputs for the image dataset and the ray generator.
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import numpy as np
|
||||
import torch
|
||||
|
||||
from nerfactory.cameras import utils as camera_utils
|
||||
from nerfactory.cameras.cameras import Cameras, CameraType
|
||||
from nerfactory.cameras.cameras import CAMERA_MODEL_TO_TYPE, Cameras, CameraType
|
||||
from nerfactory.configs import base as cfg
|
||||
from nerfactory.datamanagers.dataparsers.base import DataParser
|
||||
from nerfactory.datamanagers.structs import DatasetInputs, SceneBounds
|
||||
@@ -77,10 +77,6 @@ class Nerfactory(DataParser):
|
||||
scale_factor = 1.0 / torch.max(torch.abs(poses[:, :3, 3]))
|
||||
poses[:, :3, 3] *= scale_factor
|
||||
|
||||
distortion_params = camera_utils.get_distortion_params(
|
||||
k1=float(meta["k1"]), k2=float(meta["k2"]), p1=float(meta["p1"]), p2=float(meta["p2"])
|
||||
)
|
||||
|
||||
# in x,y,z order
|
||||
# assumes that the scene is centered at the origin
|
||||
aabb_scale = self.config.scene_scale
|
||||
@@ -90,6 +86,20 @@ class Nerfactory(DataParser):
|
||||
)
|
||||
)
|
||||
|
||||
if "camera_model" in meta:
|
||||
camera_type = CAMERA_MODEL_TO_TYPE[meta["camera_model"]]
|
||||
else:
|
||||
camera_type = CameraType.PERSPECTIVE
|
||||
|
||||
distortion_params = camera_utils.get_distortion_params(
|
||||
k1=float(meta["k1"]) if "k1" in meta else 0.0,
|
||||
k2=float(meta["k2"]) if "k2" in meta else 0.0,
|
||||
k3=float(meta["k3"]) if "k3" in meta else 0.0,
|
||||
k4=float(meta["k4"]) if "k4" in meta else 0.0,
|
||||
p1=float(meta["p1"]) if "p1" in meta else 0.0,
|
||||
p2=float(meta["p2"]) if "p2" in meta else 0.0,
|
||||
)
|
||||
|
||||
cameras = Cameras(
|
||||
fx=float(meta["fl_x"]),
|
||||
fy=float(meta["fl_y"]),
|
||||
@@ -99,7 +109,7 @@ class Nerfactory(DataParser):
|
||||
height=int(meta["h"]),
|
||||
width=int(meta["w"]),
|
||||
camera_to_worlds=poses[:, :3, :4],
|
||||
camera_type=CameraType.PERSPECTIVE,
|
||||
camera_type=camera_type,
|
||||
)
|
||||
|
||||
cameras.rescale_output_resolution(scaling_factor=1.0 / self.config.downscale_factor)
|
||||
|
||||
Reference in new issue
Block a user