Exemplo n.º 1
0
def run_dataset(data: DataSetBase, input, output) -> None:
    recs_base = data.load_reconstruction(input)
    if len(recs_base) == 0:
        return

    rec_base = recs_base[0]
    tracks_manager = data.load_tracks_manager()
    rec_base.add_correspondences_from_tracks_manager(tracks_manager)

    images = data.images()
    remaining_images = set(images) - set(rec_base.shots)
    gcp = data.load_ground_control_points()
    report = {}
    rec_report = {}
    report["extend_reconstruction"] = [rec_report]
    rec, rec_report["grow"] = reconstruction.grow_reconstruction(
        data,
        tracks_manager,
        rec_base,
        remaining_images,
        gcp,
    )
    rec_report["num_remaining_images"] = len(remaining_images)
    report["not_reconstructed_images"] = list(remaining_images)
    data.save_reconstruction([rec], output)
    data.save_report(io.json_dumps(report), "reconstruction.json")
Exemplo n.º 2
0
def run_dataset(dataset: DataSetBase, input, output) -> None:
    """Bundle a reconstructions.

    Args:
        input: input reconstruction JSON in the dataset
        output: input reconstruction JSON in the dataset

    """

    reconstructions = dataset.load_reconstruction(input)
    camera_priors = dataset.load_camera_models()
    rig_cameras_priors = dataset.load_rig_cameras()
    tracks_manager = dataset.load_tracks_manager()

    # load the tracks manager and add its observations to the reconstruction
    # go through all the points and add their shots
    for reconstruction in reconstructions:
        reconstruction.add_correspondences_from_tracks_manager(tracks_manager)
        gcp = dataset.load_ground_control_points()
        orec.bundle(reconstruction, camera_priors, rig_cameras_priors, gcp,
                    dataset.config)
    dataset.save_reconstruction(reconstructions, output)
Exemplo n.º 3
0
def invent_reference_from_gps_and_gcp(
        data: DataSetBase,
        images: Optional[List[str]] = None) -> geo.TopocentricConverter:
    lat, lon, alt = 0.0, 0.0, 0.0
    wlat, wlon, walt = 0.0, 0.0, 0.0
    if images is None:
        images = data.images()
    for image in images:
        d = data.load_exif(image)
        if "gps" in d and "latitude" in d["gps"] and "longitude" in d["gps"]:
            w = 1.0 / max(0.01, d["gps"].get("dop", 15))
            lat += w * d["gps"]["latitude"]
            lon += w * d["gps"]["longitude"]
            wlat += w
            wlon += w
            if "altitude" in d["gps"]:
                alt += w * d["gps"]["altitude"]
                walt += w

    if not wlat and not wlon:
        for gcp in data.load_ground_control_points():
            lat += gcp.lla["latitude"]
            lon += gcp.lla["longitude"]
            wlat += 1
            wlon += 1

            if gcp.has_altitude:
                alt += gcp.lla["altitude"]
                walt += 1

    if wlat:
        lat /= wlat
    if wlon:
        lon /= wlon
    if walt:
        alt /= walt

    return geo.TopocentricConverter(lat, lon, 0)  # Set altitude manually.