4
0
mirror of https://github.com/nerfstudio-project/nerfstudio.git synced 2026-11-11 02:24:38 +08:00

Use focal length

This commit is contained in:
Kevin Chen 2022-11-08 19:58:17 +00:00
parent b3efcb9bfd
commit 110d085d1a
No known key found for this signature in database
GPG Key ID: DC650012176D84EA
2 changed files with 5 additions and 6 deletions

View File

@ -315,10 +315,9 @@ class Cameras:
dim=-1,
)
elif self.camera_type[0] == CameraType.EQUIRECTANGULAR.value:
# u goes from -w/2 to w/2
# v goes from -h/2 to h/2
phi = torch.pi * (0.5 - coord_stack[..., 1] / self.image_height[camera_indices])
theta = -2 * torch.pi * coord_stack[..., 0] / self.image_width[camera_indices]
# u and v go from -1/2 to 1/2
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)],

View File

@ -605,8 +605,8 @@ 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 1.0,
"fl_y": float(cam["focal_y"]) if "focal_y" in cam else 1.0,
"fl_x": float(cam["focal_x"]) if "focal_x" in cam else float(cam["width"]),
"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"],
"w": int(cam["width"]),