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

Function read_extrinsics_binary

scene/colmap_loader.py:184–216  ·  view source on GitHub ↗

see: src/base/reconstruction.cc void Reconstruction::ReadImagesBinary(const std::string& path) void Reconstruction::WriteImagesBinary(const std::string& path)

(path_to_model_file)

Source from the content-addressed store, hash-verified

182
183
184def read_extrinsics_binary(path_to_model_file):
185 """
186 see: src/base/reconstruction.cc
187 void Reconstruction::ReadImagesBinary(const std::string& path)
188 void Reconstruction::WriteImagesBinary(const std::string& path)
189 """
190 images = {}
191 with open(path_to_model_file, "rb") as fid:
192 num_reg_images = read_next_bytes(fid, 8, "Q")[0]
193 for _ in range(num_reg_images):
194 binary_image_properties = read_next_bytes(
195 fid, num_bytes=64, format_char_sequence="idddddddi")
196 image_id = binary_image_properties[0]
197 qvec = np.array(binary_image_properties[1:5])
198 tvec = np.array(binary_image_properties[5:8])
199 camera_id = binary_image_properties[8]
200 image_name = ""
201 current_char = read_next_bytes(fid, 1, "c")[0]
202 while current_char != b"\x00": # look for the ASCII 0 entry
203 image_name += current_char.decode("utf-8")
204 current_char = read_next_bytes(fid, 1, "c")[0]
205 num_points2D = read_next_bytes(fid, num_bytes=8,
206 format_char_sequence="Q")[0]
207 x_y_id_s = read_next_bytes(fid, num_bytes=24*num_points2D,
208 format_char_sequence="ddq"*num_points2D)
209 xys = np.column_stack([tuple(map(float, x_y_id_s[0::3])),
210 tuple(map(float, x_y_id_s[1::3]))])
211 point3D_ids = np.array(tuple(map(int, x_y_id_s[2::3])))
212 images[image_id] = Image(
213 id=image_id, qvec=qvec, tvec=tvec,
214 camera_id=camera_id, name=image_name,
215 xys=xys, point3D_ids=point3D_ids)
216 return images
217
218
219def read_intrinsics_binary(path_to_model_file):

Callers 1

read_colmap_gt_poseFunction · 0.90

Calls 2

read_next_bytesFunction · 0.85
ImageClass · 0.85

Tested by

no test coverage detected