MCPcopy Create free account
hub / github.com/NVlabs/InstantSplat / readColmapCamerasInterp

Function readColmapCamerasInterp

scene/dataset_readers.py:163–211  ·  view source on GitHub ↗
(cam_extrinsics, cam_intrinsics, images_folder, model_path)

Source from the content-addressed store, hash-verified

161
162# For interpolated video, open when only render interpolated video
163def readColmapCamerasInterp(cam_extrinsics, cam_intrinsics, images_folder, model_path):
164
165 pose_interpolated_path = model_path + 'pose/pose_interpolated.npy'
166 pose_interpolated = np.load(pose_interpolated_path)
167 intr = cam_intrinsics[1]
168
169 cam_infos = []
170 poses=[]
171 for idx, pose_npy in enumerate(pose_interpolated):
172 sys.stdout.write('\r')
173 sys.stdout.write("Reading camera {}/{}".format(idx+1, pose_interpolated.shape[0]))
174 sys.stdout.flush()
175
176 extr = pose_npy
177 intr = intr
178 height = intr.height
179 width = intr.width
180
181 uid = idx
182 R = extr[:3, :3].transpose()
183 T = extr[:3, 3]
184 pose = np.vstack((np.hstack((R, T.reshape(3,-1))),np.array([[0, 0, 0, 1]])))
185 # print(uid)
186 # print(pose.shape)
187 # pose = np.linalg.inv(pose)
188 poses.append(pose)
189 if intr.model=="SIMPLE_PINHOLE":
190 focal_length_x = intr.params[0]
191 FovY = focal2fov(focal_length_x, height)
192 FovX = focal2fov(focal_length_x, width)
193 elif intr.model=="PINHOLE":
194 focal_length_x = intr.params[0]
195 focal_length_y = intr.params[1]
196 FovY = focal2fov(focal_length_y, height)
197 FovX = focal2fov(focal_length_x, width)
198 else:
199 assert False, "Colmap camera model not handled: only undistorted datasets (PINHOLE or SIMPLE_PINHOLE cameras) supported!"
200
201 images_list = os.listdir(os.path.join(images_folder))
202 image_name_0 = images_list[0]
203 image_name = str(idx).zfill(4)
204 image = Image.open(images_folder + '/' + image_name_0)
205
206 cam_info = CameraInfo(uid=uid, R=R, T=T, FovY=FovY, FovX=FovX, image=image,
207 image_path=images_folder, image_name=image_name, width=width, height=height)
208 cam_infos.append(cam_info)
209
210 sys.stdout.write('\n')
211 return cam_infos, poses
212
213
214def fetchPly(path):

Callers

nothing calls this directly

Calls 4

focal2fovFunction · 0.90
CameraInfoClass · 0.85
writeMethod · 0.80
flushMethod · 0.80

Tested by

no test coverage detected