(
    reference: types.Reconstruction, reconstruction: types.Reconstruction
)
return aligned
Align a reconstruction to a reference.
Align a reconstruction to a reference.
Align a reconstruction to a reference .
def aligned_to_reference(
    reference: types.Reconstruction, reconstruction: types.Reconstruction
) -> types.Reconstruction:
    """Align a reconstruction to a reference."""
    coords1, coords2 = [], []
    for point1 in reconstruction.points.values():
        point2 = reference.points.get(point1.id)
        if point2 is not None:
            coords1.append(point1.coordinates)
            coords2.append(point2.coordinates)

    if len(coords1) == 0 or len(coords2) == 0:
        for shot1 in reconstruction.shots.values():
            shot2 = reference.shots.get(shot1.id)
            if shot2 is not None:
                coords1.append(shot1.pose.get_origin())
                coords2.append(shot2.pose.get_origin())

    s, A, b = find_alignment(coords1, coords2)
    aligned = _copy_reconstruction(reconstruction)
    align.apply_similarity(aligned, s, A, b)
    return aligned
def aligned_to_reference ( reference : types . Reconstruction , reconstruction : types . Reconstruction ) -> types . Reconstruction : coords1 , coords2 = [ ] , [ ] for point1 in reconstruction . points . values ( ) : point2 = reference . points . get ( point1 . id ) if point2 is not None : coords1 . append ( point1 . coordinates ) coords2 . append ( point2 . coordinates ) if len ( coords1 ) == 0 or len ( coords2 ) == 0 : for shot1 in reconstruction . shots . values ( ) : shot2 = reference . shots . get ( shot1 . id ) if shot2 is not None : coords1 . append ( shot1 . pose . get_origin ( ) ) coords2 . append ( shot2 . pose . get_origin ( ) ) s , A , b = find_alignment ( coords1 , coords2 ) aligned = _copy_reconstruction ( reconstruction ) align . apply_similarity ( aligned , s , A , b ) return aligned