mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-04 06:49:13 +08:00
Add missing inits
This commit is contained in:
1 parent
31345faed5
commit
b40ec1e863
7 files changed
+101
-39
No files matched your search
@@ -0,0 +1,13 @@
|
|||||||
|
# Copyright 2022 The Plenoptix Team. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
@@ -16,50 +16,52 @@
|
|||||||
Code for camera paths.
|
Code for camera paths.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from dataclasses import dataclass
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
from pyrad.cameras.cameras import Camera, get_camera, get_intrinsics_from_intrinsics_matrix
|
from pyrad.cameras.cameras import Camera, get_camera, get_intrinsics_from_intrinsics_matrix
|
||||||
from pyrad.cameras.transformations import get_interpolated_poses, get_interpolated_poses_many
|
from pyrad.cameras.transformations import get_interpolated_poses_many
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
class CameraPath:
|
class CameraPath:
|
||||||
|
"""A camera path."""
|
||||||
|
|
||||||
|
cameras: List[Camera]
|
||||||
|
|
||||||
|
|
||||||
|
def get_interpolated_camera_path(camera_a: Camera, camera_b: Camera, steps: int) -> CameraPath:
|
||||||
|
"""Generate a camera path between two cameras.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
camera_a: The first camera.
|
||||||
|
camera_b: The second camera.
|
||||||
|
steps: The number of steps to interpolate between the two cameras.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
CameraPath: A camera path.
|
||||||
"""
|
"""
|
||||||
Base class for camera path.
|
Ka = camera_a.get_intrinsics_matrix()
|
||||||
|
pose_a = camera_a.get_camera_to_world_h()
|
||||||
|
Kb = camera_b.get_intrinsics_matrix()
|
||||||
|
pose_b = camera_b.get_camera_to_world_h()
|
||||||
|
poses = [pose_a, pose_b]
|
||||||
|
Ks = [Ka, Kb]
|
||||||
|
poses, Ks = get_interpolated_poses_many(poses, Ks, steps_per_transition=steps)
|
||||||
|
# create a list of cameras
|
||||||
|
|
||||||
|
cameras = []
|
||||||
|
for pose, K in zip(poses, Ks):
|
||||||
|
intrinsics = get_intrinsics_from_intrinsics_matrix(K)
|
||||||
|
camera_to_world = torch.from_numpy(pose[:3])
|
||||||
|
camera = get_camera(intrinsics, camera_to_world, None)
|
||||||
|
cameras.append(camera)
|
||||||
|
return CameraPath(cameras=cameras)
|
||||||
|
|
||||||
|
|
||||||
|
def get_spiral_path(camera_a: Camera, camera_b: Camera, steps: int) -> CameraPath:
|
||||||
"""
|
"""
|
||||||
|
Returns a list of camera in a sprial.
|
||||||
def __init__(self) -> None:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class InterpolatedCameraPath(CameraPath):
|
|
||||||
"""
|
"""
|
||||||
Class to interpolate between two cameras.
|
raise NotImplementedError
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, camera_a: Camera, camera_b: Camera) -> None:
|
|
||||||
super().__init__()
|
|
||||||
self.camera_a = camera_a
|
|
||||||
self.camera_b = camera_b
|
|
||||||
|
|
||||||
def get_path(self, steps: int) -> List[Camera]:
|
|
||||||
"""
|
|
||||||
Returns a list of cameras.
|
|
||||||
"""
|
|
||||||
K_a = self.camera_a.get_intrinsics_matrix()
|
|
||||||
pose_a = self.camera_a.get_camera_to_world_h()
|
|
||||||
K_b = self.camera_b.get_intrinsics_matrix()
|
|
||||||
pose_b = self.camera_b.get_camera_to_world_h()
|
|
||||||
poses = [pose_a, pose_b]
|
|
||||||
Ks = [K_a, K_b]
|
|
||||||
poses, Ks = get_interpolated_poses_many(poses, Ks, steps_per_transition=steps)
|
|
||||||
# create a list of cameras
|
|
||||||
|
|
||||||
cameras = []
|
|
||||||
for pose, K in zip(poses, Ks):
|
|
||||||
intrinsics = get_intrinsics_from_intrinsics_matrix(K)
|
|
||||||
camera_to_world = torch.from_numpy(pose[:3])
|
|
||||||
camera = get_camera(intrinsics, camera_to_world, None)
|
|
||||||
cameras.append(camera)
|
|
||||||
return cameras
|
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
Camera Models
|
Camera Models
|
||||||
"""
|
"""
|
||||||
from abc import abstractmethod
|
from abc import abstractmethod
|
||||||
from dataclasses import dataclass
|
|
||||||
from typing import Optional, Type
|
from typing import Optional, Type
|
||||||
|
|
||||||
import torch
|
import torch
|
||||||
@@ -366,7 +365,14 @@ def get_camera_model(num_intrinsics_params: int) -> Type[Camera]:
|
|||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
def get_camera(intrinsics, camera_to_world, camera_index=None):
|
def get_camera(intrinsics: TensorType["num_intrinsics"], camera_to_world: TensorType[3, 4], camera_index=None):
|
||||||
|
"""Returns a transformed camera.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
intrinsics (TensorType["num_intrinsics"]): Intrinsics tensor.
|
||||||
|
camera_to_world (TensorType[3, 4]): Camera to world transformation.
|
||||||
|
camera_index (int): Camera index.
|
||||||
|
"""
|
||||||
assert len(intrinsics.shape) == 1, "The intrinsics object should be a flat tensor."
|
assert len(intrinsics.shape) == 1, "The intrinsics object should be a flat tensor."
|
||||||
num_intrinsics_params = len(intrinsics)
|
num_intrinsics_params = len(intrinsics)
|
||||||
camera_class = get_camera_model(num_intrinsics_params)
|
camera_class = get_camera_model(num_intrinsics_params)
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
# pylint: skip-file
|
||||||
"""
|
"""
|
||||||
Camera transformation helper code.
|
Camera transformation helper code.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Copyright 2022 The Plenoptix Team. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
# Copyright 2022 The Plenoptix Team. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
@@ -1,3 +1,17 @@
|
|||||||
|
# Copyright 2022 The Plenoptix Team. All rights reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
# https://gist.github.com/jeffbass/ebf877e964c9a0b84272
|
# https://gist.github.com/jeffbass/ebf877e964c9a0b84272
|
||||||
|
|
||||||
# zmqimage.py -- classes to send, receive and display cv2 images via zmq
|
# zmqimage.py -- classes to send, receive and display cv2 images via zmq
|
||||||
|
|||||||
Reference in new issue
Block a user