From 20aaf40db02cc93c2ada81d9817e074bad7e1d0b Mon Sep 17 00:00:00 2001 From: Kevin Chen <79341521+kevinddchen@users.noreply.github.com> Date: Wed, 9 Nov 2022 06:45:30 +0000 Subject: [PATCH] Fixup --- nerfstudio/cameras/cameras.py | 5 +++-- scripts/process_data.py | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/nerfstudio/cameras/cameras.py b/nerfstudio/cameras/cameras.py index 5ca53881f..858745a49 100644 --- a/nerfstudio/cameras/cameras.py +++ b/nerfstudio/cameras/cameras.py @@ -315,9 +315,10 @@ class Cameras: dim=-1, ) elif self.camera_type[0] == CameraType.EQUIRECTANGULAR.value: - # u and v go from -1/2 to 1/2 + # u goes from -1 to 1 + # v goes from -1/2 to 1/2 (height is half of width) + theta = -torch.pi * coord_stack[..., 0] phi = torch.pi * (0.5 - coord_stack[..., 1]) - theta = -2 * torch.pi * coord_stack[..., 0] # use spherical in local camera coordinates (+y up, x=0 and z<0 is theta=0) directions_stack = torch.stack( [-torch.sin(theta) * torch.sin(phi), torch.cos(phi), -torch.cos(theta) * torch.sin(phi)], diff --git a/scripts/process_data.py b/scripts/process_data.py index dd572fcd8..2810efefb 100755 --- a/scripts/process_data.py +++ b/scripts/process_data.py @@ -605,7 +605,7 @@ 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"]) if "focal_x" in cam else float(cam["width"]), + "fl_x": float(cam["focal_x"]) if "focal_x" in cam else float(cam["height"]), "fl_y": float(cam["focal_y"]) if "focal_y" in cam else float(cam["height"]), "cx": float(cam["c_x"]) if "c_x" in cam else 0.5 * cam["width"], "cy": float(cam["c_y"]) if "c_y" in cam else 0.5 * cam["height"], @@ -714,8 +714,8 @@ class ProcessImages: summary_log = [] # Copy images to output directory - # NOTE(kchen): is this OK with COLMAP? - num_frames = copy_images(self.data, image_dir=image_dir, verbose=self.verbose, rename=False) + rename_images = self.sfm_method != "OpenSfM" # OpenSfM does not rename images + num_frames = copy_images(self.data, image_dir=image_dir, verbose=self.verbose, rename=rename_images) summary_log.append(f"Starting with {num_frames} images") # Downscale images