def generate_exifs(reconstruction, gps_noise, speed_ms=10): """Generate fake exif metadata from the reconstruction.""" previous_pose = None previous_time = 0 exifs = {} reference = geo.TopocentricConverter(0, 0, 0) for shot_name in sorted(reconstruction.shots.keys()): shot = reconstruction.shots[shot_name] exif = {} exif["width"] = shot.camera.width exif["height"] = shot.camera.height exif["focal_ratio"] = shot.camera.focal exif["camera"] = str(shot.camera.id) exif["make"] = str(shot.camera.id) pose = shot.pose.get_origin() if previous_pose is not None: previous_time += np.linalg.norm(pose - previous_pose) * speed_ms previous_pose = pose exif["capture_time"] = previous_time perturb_points([pose], [gps_noise, gps_noise, gps_noise]) _, _, _, comp = rc.shot_lla_and_compass(shot, reference) lat, lon, alt = reference.to_lla(*pose) exif["gps"] = {} exif["gps"]["latitude"] = lat exif["gps"]["longitude"] = lon exif["gps"]["altitude"] = alt exif["gps"]["dop"] = gps_noise exif["compass"] = {"angle": comp} exifs[shot_name] = exif return exifs
def generate_exifs(reconstruction, gps_noise, speed_ms=10): """ Return extracted exif information, as dictionary, usually with fields: ================ ===== =================================== Field Type Description ================ ===== =================================== width int Width of image, in pixels height int Height of image, in pixels focal_prior float Focal length (real) / sensor width ================ ===== =================================== :param image: Image name, with extension (i.e. 123.jpg) """ previous_pose = None previous_time = 0 exifs = {} reference = geo.TopocentricConverter(0, 0, 0) for shot_name in sorted(reconstruction.shots.keys()): shot = reconstruction.shots[shot_name] exif = {} exif['width'] = shot.camera.width exif['height'] = shot.camera.height exif['focal_prior'] = shot.camera.focal_prior exif['camera'] = str(shot.camera.id) exif['make'] = str(shot.camera.id) pose = shot.pose.get_origin() if previous_pose is not None: previous_time += np.linalg.norm(pose - previous_pose) * speed_ms previous_pose = pose exif['capture_time'] = previous_time perturb_points([pose], [gps_noise, gps_noise, gps_noise]) shot_copy = copy.deepcopy(shot) shot_copy.pose.set_origin(pose) lat, lon, alt, comp = rc.shot_lla_and_compass(shot_copy, reference) exif['gps'] = {} exif['gps']['latitude'] = lat exif['gps']['longitude'] = lon exif['gps']['altitude'] = alt exif['gps']['dop'] = gps_noise exif['compass'] = {'angle': comp} exifs[shot_name] = exif return exifs
def generate_exifs(reconstruction, gps_noise, speed_ms=10): """ Return extracted exif information, as dictionary, usually with fields: ================ ===== =================================== Field Type Description ================ ===== =================================== width int Width of image, in pixels height int Height of image, in pixels focal_prior float Focal length (real) / sensor width ================ ===== =================================== :param image: Image name, with extension (i.e. 123.jpg) """ previous_pose = None previous_time = 0 exifs = {} reference = geo.TopocentricConverter(0, 0, 0) for shot_name in sorted(reconstruction.shots.keys()): shot = reconstruction.shots[shot_name] exif = {} exif['width'] = shot.camera.width exif['height'] = shot.camera.height exif['focal_prior'] = shot.camera.focal_prior exif['camera'] = str(shot.camera.id) exif['make'] = str(shot.camera.id) pose = shot.pose.get_origin() if previous_pose is not None: previous_time += np.linalg.norm(pose-previous_pose)*speed_ms previous_pose = pose exif['capture_time'] = previous_time perturb_points([pose], [gps_noise, gps_noise, gps_noise]) shot_copy = copy.deepcopy(shot) shot_copy.pose.set_origin(pose) lat, lon, alt, comp = rc.shot_lla_and_compass(shot_copy, reference) exif['gps'] = {} exif['gps']['latitude'] = lat exif['gps']['longitude'] = lon exif['gps']['altitude'] = alt exif['gps']['dop'] = gps_noise exif['compass'] = {'angle': comp} exifs[shot_name] = exif return exifs
def generate_exifs(reconstruction, gps_noise, speed_ms=10): """Generate fake exif metadata from the reconstruction.""" previous_pose = None previous_time = 0 exifs = {} reference = geo.TopocentricConverter(0, 0, 0) for shot_name in sorted(reconstruction.shots.keys()): shot = reconstruction.shots[shot_name] exif = {} exif['width'] = shot.camera.width exif['height'] = shot.camera.height exif['focal_ratio'] = shot.camera.focal exif['camera'] = str(shot.camera.id) exif['make'] = str(shot.camera.id) pose = shot.pose.get_origin() if previous_pose is not None: previous_time += np.linalg.norm(pose - previous_pose) * speed_ms previous_pose = pose exif['capture_time'] = previous_time perturb_points([pose], [gps_noise, gps_noise, gps_noise]) shot_copy = copy.deepcopy(shot) shot_copy.pose.set_origin(pose) lat, lon, alt, comp = rc.shot_lla_and_compass(shot_copy, reference) exif['gps'] = {} exif['gps']['latitude'] = lat exif['gps']['longitude'] = lon exif['gps']['altitude'] = alt exif['gps']['dop'] = gps_noise exif['compass'] = {'angle': comp} exifs[shot_name] = exif return exifs
def generate_exifs( reconstruction: types.Reconstruction, reference: geo.TopocentricConverter, gps_noise: Union[Dict[str, float], float], imu_noise: float, causal_gps_noise: bool = False, ) -> Dict[str, Any]: """Generate fake exif metadata from the reconstruction.""" speed_ms = 10.0 previous_pose = None previous_time = 0 exifs = {} def _gps_dop(shot): gps_dop = 15 if isinstance(gps_noise, float): gps_dop = gps_noise if isinstance(gps_noise, dict): gps_dop = gps_noise[shot.camera.id] return gps_dop per_sequence = defaultdict(list) for shot_name in sorted(reconstruction.shots.keys()): shot = reconstruction.shots[shot_name] exif = {} exif["width"] = shot.camera.width exif["height"] = shot.camera.height exif["camera"] = str(shot.camera.id) exif["make"] = str(shot.camera.id) exif["skey"] = shot.metadata.sequence_key.value per_sequence[exif["skey"]].append(shot_name) if shot.camera.projection_type in ["perspective", "fisheye"]: exif["focal_ratio"] = shot.camera.focal pose = shot.pose.get_origin() if previous_pose is not None: previous_time += np.linalg.norm(pose - previous_pose) * speed_ms previous_pose = pose exif["capture_time"] = previous_time exifs[shot_name] = exif for sequence_images in per_sequence.values(): if causal_gps_noise: sequence_gps_dop = _gps_dop(reconstruction.shots[sequence_images[0]]) perturbations_2d = generate_causal_noise( 2, sequence_gps_dop, len(sequence_images), 2.0 ) for i, shot_name in enumerate(sequence_images): shot = reconstruction.shots[shot_name] exif = exifs[shot_name] origin = shot.pose.get_origin() if causal_gps_noise: gps_perturbation = [perturbations_2d[j][i] for j in range(2)] + [0] else: gps_noise = _gps_dop(shot) gps_perturbation = [gps_noise, gps_noise, 0] origin = np.array([origin]) perturb_points(origin, gps_perturbation) origin = origin[0] _, _, _, comp = rc.shot_lla_and_compass(shot, reference) lat, lon, alt = reference.to_lla(*origin) exif["gps"] = {} exif["gps"]["latitude"] = lat exif["gps"]["longitude"] = lon exif["gps"]["altitude"] = alt exif["gps"]["dop"] = _gps_dop(shot) omega, phi, kappa = geometry.opk_from_rotation( shot.pose.get_rotation_matrix() ) opk_noise = np.random.normal(0.0, np.full((3), imu_noise), (3)) exif["opk"] = {} exif["opk"]["omega"] = math.degrees(omega) + opk_noise[0] exif["opk"]["phi"] = math.degrees(phi) + opk_noise[1] exif["opk"]["kappa"] = math.degrees(kappa) + opk_noise[2] exif["compass"] = {"angle": comp} return exifs
def generate_exifs( reconstruction: types.Reconstruction, gps_noise: Union[Dict[str, float], float], causal_gps_noise: bool = False, ) -> Dict[str, Any]: """Generate fake exif metadata from the reconstruction.""" speed_ms = 10.0 previous_pose = None previous_time = 0 exifs = {} reference = geo.TopocentricConverter(0, 0, 0) def _gps_dop(shot): gps_dop = 15 if isinstance(gps_noise, float): gps_dop = gps_noise if isinstance(gps_noise, dict): gps_dop = gps_noise[shot.camera.id] return gps_dop per_sequence = defaultdict(list) for shot_name in sorted(reconstruction.shots.keys()): shot = reconstruction.shots[shot_name] exif = {} exif["width"] = shot.camera.width exif["height"] = shot.camera.height exif["camera"] = str(shot.camera.id) exif["make"] = str(shot.camera.id) exif["skey"] = str(shot.camera.id) per_sequence[exif["skey"]].append(shot_name) if shot.camera.projection_type in ["perspective", "fisheye"]: exif["focal_ratio"] = shot.camera.focal pose = shot.pose.get_origin() if previous_pose is not None: previous_time += np.linalg.norm(pose - previous_pose) * speed_ms previous_pose = pose exif["capture_time"] = previous_time exifs[shot_name] = exif for sequence_images in per_sequence.values(): if causal_gps_noise: sequence_gps_dop = _gps_dop( reconstruction.shots[sequence_images[0]]) perturbations_2d = generate_causal_noise(2, sequence_gps_dop, len(sequence_images), 1.0) for i, shot_name in enumerate(sequence_images): shot = reconstruction.shots[shot_name] exif = exifs[shot_name] pose = shot.pose.get_origin() if causal_gps_noise: gps_perturbation = [perturbations_2d[j][i] for j in range(2)] + [0] else: gps_noise = _gps_dop(shot) gps_perturbation = [gps_noise, gps_noise, 0] pose = np.array([pose]) perturb_points(pose, gps_perturbation) pose = pose[0] _, _, _, comp = rc.shot_lla_and_compass(shot, reference) lat, lon, alt = reference.to_lla(*pose) exif["gps"] = {} exif["gps"]["latitude"] = lat exif["gps"]["longitude"] = lon exif["gps"]["altitude"] = alt exif["gps"]["dop"] = _gps_dop(shot) exif["compass"] = {"angle": comp} return exifs