Use focal length

This commit is contained in:
Kevin Chen committed 2022-11-08 19:58:17 +00:00
1 parent b3efcb9bfd
commit 110d085d1a
2 files changed
+5 -6

No files matched your search

+3 -4
View File
@@ -315,10 +315,9 @@ class Cameras:
dim=-1, dim=-1,
) )
elif self.camera_type[0] == CameraType.EQUIRECTANGULAR.value: elif self.camera_type[0] == CameraType.EQUIRECTANGULAR.value:
# u goes from -w/2 to w/2 # u and v go from -1/2 to 1/2
# v goes from -h/2 to h/2 phi = torch.pi * (0.5 - coord_stack[..., 1])
phi = torch.pi * (0.5 - coord_stack[..., 1] / self.image_height[camera_indices]) theta = -2 * torch.pi * coord_stack[..., 0]
theta = -2 * torch.pi * coord_stack[..., 0] / self.image_width[camera_indices]
# use spherical in local camera coordinates (+y up, x=0 and z<0 is theta=0) # use spherical in local camera coordinates (+y up, x=0 and z<0 is theta=0)
directions_stack = torch.stack( directions_stack = torch.stack(
[-torch.sin(theta) * torch.sin(phi), torch.cos(phi), -torch.cos(theta) * torch.sin(phi)], [-torch.sin(theta) * torch.sin(phi), torch.cos(phi), -torch.cos(theta) * torch.sin(phi)],
+2 -2
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 # 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"]) if "focal_x" 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 1.0, "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"], "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"], "cy": float(cam["c_y"]) if "c_y" in cam else 0.5 * cam["height"],
"w": int(cam["width"]), "w": int(cam["width"]),