4
0
mirror of https://github.com/nerfstudio-project/nerfstudio.git synced 2026-11-10 18:17:31 +08:00

fixed bugs in the data processing pipeline

This commit is contained in:
Kamyar Salahi 2022-11-04 10:13:48 -07:00
parent 4120d7945d
commit 19d996ef5e
3 changed files with 16 additions and 11 deletions

View File

@ -315,9 +315,15 @@ class Cameras:
dim=-1,
)
elif self.camera_type[0] == CameraType.EQUIRECTANGULAR.value:
phi = y / self.image_height * torch.pi
theta = -x / self.image_width * 2 * torch.pi
directions = torch.stack(
coord = torch.stack([x,y ], -1)
coord_x_offset = torch.stack([x+1, y], -1)
coord_y_offset = torch.stack([x, y+1], -1)
coord_stack = torch.stack([coord, coord_x_offset, coord_y_offset], dim=0)
phi = coord_stack[..., 1] / self.image_height[camera_indices] * torch.pi
theta = coord_stack[..., 0] / self.image_width[camera_indices] * 2 * torch.pi
directions_stack = torch.stack(
[
torch.cos(theta) * torch.sin(phi),
torch.sin(theta) * torch.sin(phi),
@ -348,7 +354,7 @@ class Cameras:
if not isinstance(camera_indices, torch.Tensor):
ray_bundle_camera_indices = torch.Tensor([camera_indices]).broadcast_to(pixel_area.shape).to(self.device)
else:
ray_bundle_camera_indices = camera_indices.view(pixel_area.shape)
ray_bundle_camera_indices = camera_indices.view(pixel_area.shape)
return RayBundle(
origins=origins,

View File

@ -136,9 +136,8 @@ def collate_image_dataset_batch_equirectangular(batch: Dict, num_rays_per_batch:
# ).long()
number_of_images = torch.rand(num_rays_per_batch, device=device)
phi = torch.acos(1 - 2 * torch.rand(num_rays_per_batch, device=device)) / 2 * torch.pi
phi = torch.acos(1 - 2 * torch.rand(num_rays_per_batch, device=device)) / torch.pi
theta = torch.rand(num_rays_per_batch, device=device)
indices = torch.floor(
torch.stack((number_of_images, phi, theta), dim=-1)
* torch.tensor([num_images, image_height, image_width], device=device)

View File

@ -602,10 +602,10 @@ def opensfm_to_json(reconstruction_path: Path, output_dir: Path, camera_model: C
# For now just assume it's all the same camera
cam = cams[list(cams.keys())[0]]
out = {
"fl_x": float(cam["focal_x"]) * max(cam["height"], cam["width"]),
"fl_y": float(cam["focal_y"]) * max(cam["height"], cam["width"]),
"cx": cam["width"] / 2.0 + float(cam["c_x"]) * cam["width"],
"cy": cam["height"] / 2.0 + float(cam["c_y"]) * cam["height"],
"fl_x": float(cam["focal_x"]) * max(cam["height"], cam["width"]) if "focal_x" in cam else 1.,
"fl_y": float(cam["focal_y"]) * max(cam["height"], cam["width"]) if "focal_y" in cam else 1.,
"cx": cam["width"] / 2.0 + float(cam["c_x"]) * cam["width"] if "c_x" in cam else 1. ,
"cy": cam["height"] / 2.0 + float(cam["c_y"]) * cam["height"] if "c_y" in cam else 1. ,
"w": cam["width"],
"h": cam["height"],
"camera_model": camera_model.value,
@ -946,7 +946,7 @@ class ProcessInsta360:
gpu=self.gpu,
verbose=self.verbose,
matching_method=self.matching_method,
opensfm_install=
opensfm_install=Path("/scratch2/ksalahi/OpenSfM")
)
# Save transforms.json