Ejemplo n.º 1
0
def _transform_dense_point_cloud(udata: UndistortedDataSet, transformation,
                                 output_path):
    """Apply a transformation to the merged point cloud."""
    A, b = transformation[:3, :3], transformation[:3, 3]
    input_path = udata.point_cloud_file()
    with io.open_rt(input_path) as fin:
        with io.open_wt(output_path) as fout:
            for i, line in enumerate(fin):
                if i < 13:
                    fout.write(line)
                else:
                    x, y, z, nx, ny, nz, red, green, blue = line.split()
                    x, y, z = np.dot(A, map(float, [x, y, z])) + b
                    nx, ny, nz = np.dot(A, map(float, [nx, ny, nz]))
                    fout.write("{} {} {} {} {} {} {} {} {}\n".format(
                        x, y, z, nx, ny, nz, red, green, blue))
Ejemplo n.º 2
0
def merge_depthmaps(data: UndistortedDataSet, reconstruction):
    """Merge depthmaps into a single point cloud."""
    logger.info("Merging depthmaps")

    shot_ids = [
        s for s in reconstruction.shots if data.pruned_depthmap_exists(s)
    ]

    if not shot_ids:
        logger.warning("Depthmaps contain no points.  Try using more images.")
        return

    def depthmap_provider(shot_id):
        return data.load_pruned_depthmap(shot_id)

    merge_depthmaps_from_provider(data, shot_ids, depthmap_provider,
                                  data.point_cloud_file())