Fix crop robustness (#1321)

This commit is contained in:
Matthew Tancik authored and GitHub committed 2023-01-31 18:25:30 -08:00
1 parent f3b3a517e8
commit 79395ecd8d
2 files changed
+10 -4

No files matched your search

+9 -3
View File
@@ -147,6 +147,8 @@ class Cameras(TensorDataclass):
self.__post_init__() # This will do the dataclass post_init and broadcast all the tensors
self._use_nerfacc = strtobool(os.environ.get("INTERSECT_WITH_NERFACC", "TRUE"))
def _init_get_fc_xy(self, fc_xy, name):
"""
Parses the input focal length / principle point x or y and returns a tensor of the correct shape
@@ -470,9 +472,13 @@ class Cameras(TensorDataclass):
rays_o = rays_o.reshape((-1, 3))
rays_d = rays_d.reshape((-1, 3))
if strtobool(os.environ.get("INTERSECT_WITH_NERFACC", "TRUE")):
nerfacc = importlib.import_module("nerfacc")
t_min, t_max = nerfacc.ray_aabb_intersect(rays_o, rays_d, tensor_aabb)
if self._use_nerfacc:
try:
nerfacc = importlib.import_module("nerfacc")
t_min, t_max = nerfacc.ray_aabb_intersect(rays_o, rays_d, tensor_aabb)
except: # pylint: disable=bare-except
t_min, t_max = nerfstudio.utils.math.intersect_aabb(rays_o, rays_d, tensor_aabb)
self._use_nerfacc = False
else:
t_min, t_max = nerfstudio.utils.math.intersect_aabb(rays_o, rays_d, tensor_aabb)