MCPcopy Index your code
hub / github.com/DNA-Rendering/DNA-Rendering / readColmapCameras

Function readColmapCameras

scripts/3DGS/dataset_readers.py:78–115  ·  view source on GitHub ↗
(cam_extrinsics, cam_intrinsics, images_folder)

Source from the content-addressed store, hash-verified

76 return {"translate": translate, "radius": radius}
77
78def readColmapCameras(cam_extrinsics, cam_intrinsics, images_folder):
79 cam_infos = []
80 for idx, key in enumerate(cam_extrinsics):
81 sys.stdout.write('\r')
82 # the exact output you're looking for:
83 sys.stdout.write("Reading camera {}/{}".format(idx+1, len(cam_extrinsics)))
84 sys.stdout.flush()
85
86 extr = cam_extrinsics[key]
87 intr = cam_intrinsics[extr.camera_id]
88 height = intr.height
89 width = intr.width
90
91 uid = intr.id
92 R = np.transpose(qvec2rotmat(extr.qvec))
93 T = np.array(extr.tvec)
94
95 if intr.model=="SIMPLE_PINHOLE":
96 focal_length_x = intr.params[0]
97 FovY = focal2fov(focal_length_x, height)
98 FovX = focal2fov(focal_length_x, width)
99 elif intr.model=="PINHOLE":
100 focal_length_x = intr.params[0]
101 focal_length_y = intr.params[1]
102 FovY = focal2fov(focal_length_y, height)
103 FovX = focal2fov(focal_length_x, width)
104 else:
105 assert False, "Colmap camera model not handled: only undistorted datasets (PINHOLE or SIMPLE_PINHOLE cameras) supported!"
106
107 image_path = os.path.join(images_folder, os.path.basename(extr.name))
108 image_name = os.path.basename(image_path).split(".")[0]
109 image = Image.open(image_path)
110
111 cam_info = CameraInfo(uid=uid, R=R, T=T, FovY=FovY, FovX=FovX, image=image,
112 image_path=image_path, image_name=image_name, width=width, height=height)
113 cam_infos.append(cam_info)
114 sys.stdout.write('\n')
115 return cam_infos
116
117def fetchPly(path):
118 plydata = PlyData.read(path)

Callers 1

readColmapSceneInfoFunction · 0.85

Calls 2

focal2fovFunction · 0.90
CameraInfoClass · 0.85

Tested by

no test coverage detected