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