mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-18 22:04:02 +08:00
Flesh out viewer beta (#2086)
* Increase max_res of first proposal network * fix render statemachine logic for viewer beta * clicking on cameras in the viewer * fix fov calculation, update camera positions while training * cleanup * backup * fix configure theme * Fix theme configure for latest dev version of viser * Fix runtime errors * add set up direction button * add pause resume button * Export panel * Render tab skeleton * make responsiveness more snappy by stopping training * depth composite * start implementing viewercontrol in new viewer * refactor background img to use depth and add depth layering option * show/hide images * speed up rendering * fix crop color background * crop * rotated crops * rotated crops * transform handle on crop box * fix xyzw for crop * oriented crop export for pointclouds, not for meshes yet * Initial render panel * Fix export button * Theme tweaks * fix background issue in cropping * export rotated poisson meshe * double normals definition in export panel * Visual nits * remove tsdf from export panel * Add licenses * Fix some CI errors * Type fixes * Fix tests * Fix numpy broken * various bugfix --------- Co-authored-by: Brent Yi <yibrenth@gmail.com> Co-authored-by: terrancewang <terrance.3512@gmail.com>
This commit is contained in:
16 files changed
+1367
-162
No files matched your search
@@ -21,7 +21,7 @@ import torch
|
||||
from jaxtyping import Bool, Float
|
||||
from torch import Tensor
|
||||
|
||||
from nerfstudio.utils.misc import torch_compile
|
||||
from nerfstudio.data.scene_box import OrientedBox
|
||||
|
||||
|
||||
def components_from_spherical_harmonics(
|
||||
@@ -199,7 +199,7 @@ def expected_sin(x_means: torch.Tensor, x_vars: torch.Tensor) -> torch.Tensor:
|
||||
return torch.exp(-0.5 * x_vars) * torch.sin(x_means)
|
||||
|
||||
|
||||
@torch_compile(dynamic=True, mode="reduce-overhead", backend="eager")
|
||||
# @torch_compile(dynamic=True, mode="reduce-overhead", backend="eager")
|
||||
def intersect_aabb(
|
||||
origins: torch.Tensor,
|
||||
directions: torch.Tensor,
|
||||
@@ -240,6 +240,42 @@ def intersect_aabb(
|
||||
return t_min, t_max
|
||||
|
||||
|
||||
def intersect_obb(
|
||||
origins: torch.Tensor,
|
||||
directions: torch.Tensor,
|
||||
obb: OrientedBox,
|
||||
max_bound: float = 1e10,
|
||||
invalid_value: float = 1e10,
|
||||
):
|
||||
"""
|
||||
Ray intersection with an oriented bounding box (OBB)
|
||||
|
||||
Args:
|
||||
origins: [N,3] tensor of 3d positions
|
||||
directions: [N,3] tensor of normalized directions
|
||||
R: [3,3] rotation matrix
|
||||
T: [3] translation vector
|
||||
S: [3] extents of the bounding box
|
||||
max_bound: Maximum value of t_max
|
||||
invalid_value: Value to return in case of no intersection
|
||||
"""
|
||||
# Transform ray to OBB space
|
||||
R, T, S = obb.R, obb.T, obb.S.to(origins.device)
|
||||
H = torch.eye(4, device=origins.device, dtype=origins.dtype)
|
||||
H[:3, :3] = R
|
||||
H[:3, 3] = T
|
||||
H_world2bbox = torch.inverse(H)
|
||||
origins = torch.cat((origins, torch.ones_like(origins[..., :1])), dim=-1)
|
||||
origins = torch.matmul(H_world2bbox, origins.T).T[..., :3]
|
||||
directions = torch.matmul(H_world2bbox[:3, :3], directions.T).T
|
||||
|
||||
# Compute intersection with axis-aligned bounding box with min as -S and max as +S
|
||||
aabb = torch.concat((-S / 2, S / 2))
|
||||
t_min, t_max = intersect_aabb(origins, directions, aabb, max_bound=max_bound, invalid_value=invalid_value)
|
||||
|
||||
return t_min, t_max
|
||||
|
||||
|
||||
def safe_normalize(
|
||||
vectors: Float[Tensor, "*batch_dim N"],
|
||||
eps: float = 1e-10,
|
||||
|
||||
Reference in new issue
Block a user