mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-27 03:20:34 +08:00
Expose viewer controls to pipeline (#1804)
* Increase max_res of first proposal network * start on ViewerCamera * crop controls exposed * lint * fix viewer crash when invisible element has its value set * fov, look_at, and camera type * stuff * set update interval correctly in cameracontrols, smooth transitions work now * demo with depth zooming * depth min * WIP adding click message * put the clock back in viewerwindow * use setlookat when pos and target are defined at the same time * remove demo from nerfacto * Add click commands as rays (origin, direction) * short doc * Fix double event for doubleclick * add ViewerClick, cleanup docs * add docs * cleanup * remove scripts * remove nerfacto changes * js compile things * update viewer version * fix mutable state thing * docs improvements * add kwarg value for enableTransition * fix * lint * path in sync-defs * Misc doc edits requested in pr * Add click description * WIP remove redefinition of banner_height, refer to SCSS vars * add docstring * radix * radix * speed --------- Co-authored-by: Chung Min Kim <chungmin99@gmail.com>
This commit is contained in:
1 parent
bb9d89cd23
commit
0ee63cb581
21 files changed
+479
-93
No files matched your search
@@ -22,12 +22,11 @@ from typing import TYPE_CHECKING, Any, Dict, Literal, Optional, Tuple, get_args
|
||||
|
||||
import torch
|
||||
|
||||
from nerfstudio.cameras.cameras import Cameras, CameraType
|
||||
from nerfstudio.cameras.cameras import Cameras
|
||||
from nerfstudio.model_components.renderers import background_color_override_context
|
||||
from nerfstudio.utils import colormaps, writer
|
||||
from nerfstudio.utils.writer import GLOBAL_BUFFER, EventName, TimeWriter
|
||||
from nerfstudio.viewer.server import viewer_utils
|
||||
from nerfstudio.viewer.server.utils import get_intrinsics_matrix_and_camera_to_world_h
|
||||
from nerfstudio.viewer.viser.messages import CameraMessage
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -124,40 +123,8 @@ class RenderStateMachine(threading.Thread):
|
||||
|
||||
image_height, image_width = self._calculate_image_res(cam_msg.aspect)
|
||||
|
||||
intrinsics_matrix, camera_to_world_h = get_intrinsics_matrix_and_camera_to_world_h(
|
||||
cam_msg, image_height=image_height, image_width=image_width
|
||||
)
|
||||
|
||||
camera_to_world = camera_to_world_h[:3, :]
|
||||
camera_to_world = torch.stack(
|
||||
[
|
||||
camera_to_world[0, :],
|
||||
camera_to_world[2, :],
|
||||
camera_to_world[1, :],
|
||||
],
|
||||
dim=0,
|
||||
)
|
||||
|
||||
camera_type_msg = cam_msg.camera_type
|
||||
if camera_type_msg == "perspective":
|
||||
camera_type = CameraType.PERSPECTIVE
|
||||
elif camera_type_msg == "fisheye":
|
||||
camera_type = CameraType.FISHEYE
|
||||
elif camera_type_msg == "equirectangular":
|
||||
camera_type = CameraType.EQUIRECTANGULAR
|
||||
else:
|
||||
camera_type = CameraType.PERSPECTIVE
|
||||
|
||||
camera = Cameras(
|
||||
fx=intrinsics_matrix[0, 0],
|
||||
fy=intrinsics_matrix[1, 1],
|
||||
cx=intrinsics_matrix[0, 2],
|
||||
cy=intrinsics_matrix[1, 2],
|
||||
camera_type=camera_type,
|
||||
camera_to_worlds=camera_to_world[None, ...],
|
||||
times=torch.tensor([self.viewer.control_panel.time], dtype=torch.float32),
|
||||
)
|
||||
camera = camera.to(self.viewer.get_model().device)
|
||||
camera: Optional[Cameras] = self.viewer.get_camera(image_height, image_width)
|
||||
assert camera is not None, "render called before viewer connected"
|
||||
|
||||
with self.viewer.train_lock if self.viewer.train_lock is not None else contextlib.nullcontext():
|
||||
camera_ray_bundle = camera.generate_rays(camera_indices=0, aabb_box=self.viewer.get_model().render_aabb)
|
||||
|
||||
Reference in new issue
Block a user