Rename scene bounds (#605)

This commit is contained in:
Matthew Tancik authored and GitHub committed 2022-10-01 20:41:36 -07:00
1 parent bc2aa64aba
commit 4110bd7a3e
25 files changed
+98 -102

No files matched your search

@@ -27,7 +27,7 @@ from torchtyping import TensorType
import nerfstudio.configs.base_config as cfg
from nerfstudio.cameras.cameras import Cameras
from nerfstudio.configs.config_utils import to_immutable_dict
from nerfstudio.data.scene_box import SceneBounds
from nerfstudio.data.scene_box import SceneBox
@dataclass
@@ -58,8 +58,8 @@ class DataparserOutputs:
"""Camera object storing collection of camera information in dataset"""
alpha_color: Optional[TensorType[3]] = None
"""color of dataset background"""
scene_bounds: SceneBounds = SceneBounds()
"""scene bounds of dataset"""
scene_box: SceneBox = SceneBox()
"""scene box of dataset. Could be used to bound the scene, or to provide the scene scale depending on model."""
# we support additional input information/formats including mask/depth/semantics.
additional_inputs: Dict[str, Any] = to_immutable_dict({})
"""Dictionary of additional dataset information (e.g. semantics/point clouds/masks).
@@ -29,7 +29,7 @@ from nerfstudio.data.dataparsers.base_dataparser import (
DataParserConfig,
DataparserOutputs,
)
from nerfstudio.data.scene_box import SceneBounds
from nerfstudio.data.scene_box import SceneBox
from nerfstudio.utils.colors import get_color
from nerfstudio.utils.io import load_from_json
@@ -88,7 +88,7 @@ class Blender(DataParser):
# in x,y,z order
camera_to_world[..., 3] *= self.scale_factor
scene_bounds = SceneBounds(aabb=torch.tensor([[-1.5, -1.5, -1.5], [1.5, 1.5, 1.5]], dtype=torch.float32))
scene_box = SceneBox(aabb=torch.tensor([[-1.5, -1.5, -1.5], [1.5, 1.5, 1.5]], dtype=torch.float32))
cameras = Cameras(
camera_to_worlds=camera_to_world,
@@ -103,7 +103,7 @@ class Blender(DataParser):
image_filenames=image_filenames,
cameras=cameras,
alpha_color=alpha_color_tensor,
scene_bounds=scene_bounds,
scene_box=scene_box,
)
return dataset_inputs
@@ -31,7 +31,7 @@ from nerfstudio.data.dataparsers.base_dataparser import (
DataparserOutputs,
Semantics,
)
from nerfstudio.data.scene_box import SceneBounds
from nerfstudio.data.scene_box import SceneBox
from nerfstudio.utils.io import load_from_json
CONSOLE = Console()
@@ -122,18 +122,18 @@ class Friends(DataParser):
scene_scale = self.config.scene_scale
# -- set the scene bounds ---
scene_bounds = SceneBounds(aabb=bbox)
# -- set the scene box ---
scene_box = SceneBox(aabb=bbox)
# center the box and adjust the cameras too
center = scene_bounds.get_center()
scene_bounds.aabb -= center
center = scene_box.get_center()
scene_box.aabb -= center
camera_to_worlds[..., 3] -= center
# scale the longest dimension to match the cube size
lengths = scene_bounds.aabb[1] - scene_bounds.aabb[0]
lengths = scene_box.aabb[1] - scene_box.aabb[0]
longest_dim = torch.argmax(lengths)
longest_length = lengths[longest_dim]
scale = scene_scale / longest_length
scene_bounds.aabb = scene_bounds.aabb * scale # box
scene_box.aabb = scene_box.aabb * scale # box
camera_to_worlds[..., 3] *= scale # cameras
# --- semantics ---
@@ -185,7 +185,7 @@ class Friends(DataParser):
dataset_inputs = DataparserOutputs(
image_filenames=image_filenames,
cameras=cameras,
scene_bounds=scene_bounds,
scene_box=scene_box,
additional_inputs={"semantics": {"func": get_semantics_and_masks, "kwargs": {"semantics": semantics}}},
)
return dataset_inputs
@@ -31,7 +31,7 @@ from nerfstudio.data.dataparsers.base_dataparser import (
DataParserConfig,
DataparserOutputs,
)
from nerfstudio.data.scene_box import SceneBounds
from nerfstudio.data.scene_box import SceneBox
from nerfstudio.utils.io import load_from_json
@@ -88,7 +88,7 @@ class InstantNGP(DataParser):
# in x,y,z order
# assumes that the scene is centered at the origin
aabb_scale = meta["aabb_scale"]
scene_bounds = SceneBounds(
scene_box = SceneBox(
aabb=torch.tensor(
[[-aabb_scale, -aabb_scale, -aabb_scale], [aabb_scale, aabb_scale, aabb_scale]], dtype=torch.float32
)
@@ -110,7 +110,7 @@ class InstantNGP(DataParser):
dataset_inputs = DataparserOutputs(
image_filenames=image_filenames,
cameras=cameras,
scene_bounds=scene_bounds,
scene_box=scene_box,
)
return dataset_inputs
@@ -29,7 +29,7 @@ from nerfstudio.data.dataparsers.base_dataparser import (
DataParserConfig,
DataparserOutputs,
)
from nerfstudio.data.scene_box import SceneBounds
from nerfstudio.data.scene_box import SceneBox
@dataclass
@@ -142,7 +142,7 @@ class Mipnerf360(DataParser):
intrinsics *= torch.tensor([cx, cy, focal_length])
aabb = torch.tensor([[-4, -4, -4], [4, 4, 4]], dtype=torch.float32) * self.config.aabb_scale
scene_bounds = SceneBounds(aabb=aabb)
scene_box = SceneBox(aabb=aabb)
cameras = Cameras(
fx=focal_length,
@@ -158,7 +158,7 @@ class Mipnerf360(DataParser):
dataset_inputs = DataparserOutputs(
image_filenames=image_filenames,
cameras=cameras,
scene_bounds=scene_bounds,
scene_box=scene_box,
)
return dataset_inputs
@@ -31,7 +31,7 @@ from nerfstudio.data.dataparsers.base_dataparser import (
DataParserConfig,
DataparserOutputs,
)
from nerfstudio.data.scene_box import SceneBounds
from nerfstudio.data.scene_box import SceneBox
from nerfstudio.utils.io import load_from_json
@@ -123,7 +123,7 @@ class Nerfstudio(DataParser):
# in x,y,z order
# assumes that the scene is centered at the origin
aabb_scale = self.config.scene_scale
scene_bounds = SceneBounds(
scene_box = SceneBox(
aabb=torch.tensor(
[[-aabb_scale, -aabb_scale, -aabb_scale], [aabb_scale, aabb_scale, aabb_scale]], dtype=torch.float32
)
@@ -160,6 +160,6 @@ class Nerfstudio(DataParser):
dataset_inputs = DataparserOutputs(
image_filenames=image_filenames,
cameras=cameras,
scene_bounds=scene_bounds,
scene_box=scene_box,
)
return dataset_inputs
@@ -30,7 +30,7 @@ from nerfstudio.data.dataparsers.base_dataparser import (
DataParserConfig,
DataparserOutputs,
)
from nerfstudio.data.scene_box import SceneBounds
from nerfstudio.data.scene_box import SceneBox
from nerfstudio.utils import poses as pose_utils
from nerfstudio.utils.io import load_from_json
@@ -132,9 +132,8 @@ class Record3D(DataParser):
intrinsics = torch.ones((num_cameras, num_intrinsics_params), dtype=torch.float32)
intrinsics *= torch.tensor([cx, cy, focal_length])
# scene_bounds = SceneBounds.from_camera_poses(camera_to_world, self.config.aabb_scale)
aabb = torch.tensor([[-1, -1, -1], [1, 1, 1]], dtype=torch.float32) * self.config.aabb_scale
scene_bounds = SceneBounds(aabb=aabb)
scene_box = SceneBox(aabb=aabb)
cameras = Cameras(
fx=focal_length,
@@ -148,7 +147,7 @@ class Record3D(DataParser):
dataset_inputs = DataparserOutputs(
image_filenames=image_filenames,
cameras=cameras,
scene_bounds=scene_bounds,
scene_box=scene_box,
)
return dataset_inputs