see: src/base/reconstruction.cc void Reconstruction::ReadImagesBinary(const std::string& path) void Reconstruction::WriteImagesBinary(const std::string& path)
(path_to_model_file)
| 166 | return cameras |
| 167 | |
| 168 | def read_extrinsics_binary(path_to_model_file): |
| 169 | """ |
| 170 | see: src/base/reconstruction.cc |
| 171 | void Reconstruction::ReadImagesBinary(const std::string& path) |
| 172 | void Reconstruction::WriteImagesBinary(const std::string& path) |
| 173 | """ |
| 174 | images = {} |
| 175 | with open(path_to_model_file, "rb") as fid: |
| 176 | num_reg_images = read_next_bytes(fid, 8, "Q")[0] |
| 177 | for _ in range(num_reg_images): |
| 178 | binary_image_properties = read_next_bytes( |
| 179 | fid, num_bytes=64, format_char_sequence="idddddddi") |
| 180 | image_id = binary_image_properties[0] |
| 181 | qvec = np.array(binary_image_properties[1:5]) |
| 182 | tvec = np.array(binary_image_properties[5:8]) |
| 183 | camera_id = binary_image_properties[8] |
| 184 | image_name = "" |
| 185 | current_char = read_next_bytes(fid, 1, "c")[0] |
| 186 | while current_char != b"\x00": # look for the ASCII 0 entry |
| 187 | image_name += current_char.decode("utf-8") |
| 188 | current_char = read_next_bytes(fid, 1, "c")[0] |
| 189 | num_points2D = read_next_bytes(fid, num_bytes=8, |
| 190 | format_char_sequence="Q")[0] |
| 191 | x_y_id_s = read_next_bytes(fid, num_bytes=24*num_points2D, |
| 192 | format_char_sequence="ddq"*num_points2D) |
| 193 | xys = np.column_stack([tuple(map(float, x_y_id_s[0::3])), |
| 194 | tuple(map(float, x_y_id_s[1::3]))]) |
| 195 | point3D_ids = np.array(tuple(map(int, x_y_id_s[2::3]))) |
| 196 | images[image_id] = Image( |
| 197 | id=image_id, qvec=qvec, tvec=tvec, |
| 198 | camera_id=camera_id, name=image_name, |
| 199 | xys=xys, point3D_ids=point3D_ids) |
| 200 | return images |
| 201 | |
| 202 | |
| 203 | def read_intrinsics_binary(path_to_model_file): |
no test coverage detected