mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-11-25 18:39:55 +08:00
most code for nerf running
This commit is contained in:
1 parent
c2f3c06b6c
commit
be6fbe799e
16 files changed
+223
-168
No files matched your search
@@ -5,6 +5,7 @@ import random
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
|
||||
import torch
|
||||
from torchtyping import TensorType
|
||||
|
||||
|
||||
@@ -65,3 +66,46 @@ class CameraRayBundle:
|
||||
origins: TensorType["image_height", "image_width", 3]
|
||||
directions: TensorType["image_height", "image_width", 3]
|
||||
camera_index: int = None
|
||||
|
||||
|
||||
@dataclass
|
||||
class RaySamples:
|
||||
"""_summary_
|
||||
|
||||
Args:
|
||||
t_min: maximum times
|
||||
t_max: minimum times
|
||||
ts: time steps
|
||||
"""
|
||||
|
||||
t_min: TensorType["num_rays"]
|
||||
t_max: TensorType["num_rays"]
|
||||
ts: TensorType["num_rays", "num_samples+1"] # TODO(ethan): check with Matt about this. 2nd dimension is num_samples+1
|
||||
|
||||
def get_positions(self, ray_bundle: RayBundle) -> TensorType["num_rays", "num_samples", 3]:
|
||||
"""Returns positions."""
|
||||
# TODO(ethan): check with Matt about this
|
||||
t_mid = (self.ts[:, 1:] + self.ts[:, :-1]) / 2 # (num_rays, num_samples)
|
||||
return ray_bundle.origins[:, None] + t_mid[:, :, None] * ray_bundle.directions[:, None]
|
||||
|
||||
def get_starts(self):
|
||||
"""_summary_
|
||||
|
||||
Returns:
|
||||
_type_: _description_
|
||||
"""
|
||||
t_mid = (self.ts[:, 1:] + self.ts[:, :-1]) / 2
|
||||
return torch.cat([self.t_min[:, None], t_mid], dim=-1)
|
||||
|
||||
def get_ends(self):
|
||||
"""_summary_
|
||||
|
||||
Returns:
|
||||
_type_: _description_
|
||||
"""
|
||||
t_mid = (self.ts[:, 1:] + self.ts[:, :-1]) / 2
|
||||
return torch.cat([t_mid, self.t_max[:, None]], dim=-1)
|
||||
|
||||
def get_deltas(self) -> TensorType["num_samples"]:
|
||||
"""Returns deltas."""
|
||||
return self.get_ends() - self.get_starts()
|
||||
Reference in new issue
Block a user