see: src/base/reconstruction.cc void Reconstruction::ReadImagesText(const std::string& path) void Reconstruction::WriteImagesText(const std::string& path)
(images, path)
| 260 | |
| 261 | |
| 262 | def write_images_text(images, path): |
| 263 | """ |
| 264 | see: src/base/reconstruction.cc |
| 265 | void Reconstruction::ReadImagesText(const std::string& path) |
| 266 | void Reconstruction::WriteImagesText(const std::string& path) |
| 267 | """ |
| 268 | if len(images) == 0: |
| 269 | mean_observations = 0 |
| 270 | else: |
| 271 | mean_observations = sum((len(img.point3D_ids) for _, img in images.items()))/len(images) |
| 272 | HEADER = "# Image list with two lines of data per image:\n" + \ |
| 273 | "# IMAGE_ID, QW, QX, QY, QZ, TX, TY, TZ, CAMERA_ID, NAME\n" + \ |
| 274 | "# POINTS2D[] as (X, Y, POINT3D_ID)\n" + \ |
| 275 | "# Number of images: {}, mean observations per image: {}\n".format(len(images), mean_observations) |
| 276 | |
| 277 | with open(path, "w") as fid: |
| 278 | fid.write(HEADER) |
| 279 | for _, img in images.items(): |
| 280 | image_header = [img.id, *img.qvec, *img.tvec, img.camera_id, img.name] |
| 281 | first_line = " ".join(map(str, image_header)) |
| 282 | fid.write(first_line + "\n") |
| 283 | |
| 284 | points_strings = [] |
| 285 | for xy, point3D_id in zip(img.xys, img.point3D_ids): |
| 286 | points_strings.append(" ".join(map(str, [*xy, point3D_id]))) |
| 287 | fid.write(" ".join(points_strings) + "\n") |
| 288 | |
| 289 | |
| 290 | def write_images_binary(images, path_to_model_file): |