mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-06 07:48:50 +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
@@ -16,50 +16,52 @@
|
||||
Code for camera paths.
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import List
|
||||
|
||||
import torch
|
||||
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
|
||||
import numpy as np
|
||||
from pyrad.cameras.transformations import get_interpolated_poses_many
|
||||
|
||||
|
||||
@dataclass
|
||||
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:
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
|
||||
|
||||
class InterpolatedCameraPath(CameraPath):
|
||||
Returns a list of camera in a sprial.
|
||||
"""
|
||||
Class to interpolate between two cameras.
|
||||
"""
|
||||
|
||||
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
|
||||
raise NotImplementedError
|
||||
Reference in new issue
Block a user