def add_points_to_reconstruction( points: np.ndarray, color: np.ndarray, reconstruction: types.Reconstruction ): shift = len(reconstruction.points) for i in range(points.shape[0]): point = reconstruction.create_point(str(shift + i), points[i, :]) point.color = color
def point_from_json( reconstruction: types.Reconstruction, key: str, obj: Dict[str, Any] ) -> pymap.Landmark: """ Read a point from a json object """ point = reconstruction.create_point(key, obj["coordinates"]) point.color = obj["color"] return point
def check_merge_partial_reconstructions(self): if self.reconstructed(): data = DataSet(self.opensfm_project_path) reconstructions = data.load_reconstruction() tracks_manager = data.load_tracks_manager() if len(reconstructions) > 1: log.ODM_WARNING( "Multiple reconstructions detected (%s), this might be an indicator that some areas did not have sufficient overlap" % len(reconstructions)) log.ODM_INFO("Attempting merge") merged = Reconstruction() merged.set_reference(reconstructions[0].reference) for ix_r, rec in enumerate(reconstructions): if merged.reference != rec.reference: # Should never happen continue log.ODM_INFO("Merging reconstruction %s" % ix_r) for camera in rec.cameras.values(): merged.add_camera(camera) for point in rec.points.values(): try: new_point = merged.create_point( point.id, point.coordinates) new_point.color = point.color except RuntimeError as e: log.ODM_WARNING("Cannot merge shot id %s (%s)" % (shot.id, str(e))) continue for shot in rec.shots.values(): merged.add_shot(shot) try: obsdict = tracks_manager.get_shot_observations( shot.id) except RuntimeError: log.ODM_WARNING( "Shot id %s missing from tracks_manager!" % shot.id) continue for track_id, obs in obsdict.items(): if track_id in merged.points: merged.add_observation(shot.id, track_id, obs) data.save_reconstruction([merged])