fixed bugs in the data processing pipeline

This commit is contained in:
Kamyar Salahi committed 2022-11-04 10:13:48 -07:00
1 parent 4120d7945d
commit 19d996ef5e
3 files changed
+16 -11

No files matched your search

+10 -4
View File
@@ -315,9 +315,15 @@ class Cameras:
dim=-1, dim=-1,
) )
elif self.camera_type[0] == CameraType.EQUIRECTANGULAR.value: elif self.camera_type[0] == CameraType.EQUIRECTANGULAR.value:
phi = y / self.image_height * torch.pi coord = torch.stack([x,y ], -1)
theta = -x / self.image_width * 2 * torch.pi coord_x_offset = torch.stack([x+1, y], -1)
directions = torch.stack( 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.cos(theta) * torch.sin(phi),
torch.sin(theta) * torch.sin(phi), torch.sin(theta) * torch.sin(phi),
@@ -348,7 +354,7 @@ class Cameras:
if not isinstance(camera_indices, torch.Tensor): if not isinstance(camera_indices, torch.Tensor):
ray_bundle_camera_indices = torch.Tensor([camera_indices]).broadcast_to(pixel_area.shape).to(self.device) ray_bundle_camera_indices = torch.Tensor([camera_indices]).broadcast_to(pixel_area.shape).to(self.device)
else: else:
ray_bundle_camera_indices = camera_indices.view(pixel_area.shape) ray_bundle_camera_indices = camera_indices.view(pixel_area.shape)
return RayBundle( return RayBundle(
origins=origins, origins=origins,
+1 -2
View File
@@ -136,9 +136,8 @@ def collate_image_dataset_batch_equirectangular(batch: Dict, num_rays_per_batch:
# ).long() # ).long()
number_of_images = torch.rand(num_rays_per_batch, device=device) 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) theta = torch.rand(num_rays_per_batch, device=device)
indices = torch.floor( indices = torch.floor(
torch.stack((number_of_images, phi, theta), dim=-1) torch.stack((number_of_images, phi, theta), dim=-1)
* torch.tensor([num_images, image_height, image_width], device=device) * torch.tensor([num_images, image_height, image_width], device=device)
+5 -5
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 # For now just assume it's all the same camera
cam = cams[list(cams.keys())[0]] cam = cams[list(cams.keys())[0]]
out = { out = {
"fl_x": float(cam["focal_x"]) * max(cam["height"], cam["width"]), "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"]), "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"], "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"], "cy": cam["height"] / 2.0 + float(cam["c_y"]) * cam["height"] if "c_y" in cam else 1. ,
"w": cam["width"], "w": cam["width"],
"h": cam["height"], "h": cam["height"],
"camera_model": camera_model.value, "camera_model": camera_model.value,
@@ -946,7 +946,7 @@ class ProcessInsta360:
gpu=self.gpu, gpu=self.gpu,
verbose=self.verbose, verbose=self.verbose,
matching_method=self.matching_method, matching_method=self.matching_method,
opensfm_install= opensfm_install=Path("/scratch2/ksalahi/OpenSfM")
) )
# Save transforms.json # Save transforms.json