def _extract_exif(self, image, gps_points, data): # EXIF data in Image d = exif.extract_exif_from_file( data.open_image_file(image), data ) lla_fen_spl_comp = gps_points.get( image ) if lla_fen_spl_comp is not None: gps_md = d.get('gps') if gps_md is None: gps_md = {} d['gps'] = gps_md gps_md['latitude'] = lla_fen_spl_comp[0] gps_md['longitude'] = lla_fen_spl_comp[1] gps_md['altitude'] = lla_fen_spl_comp[2] gps_md['dop'] = data.config.get( 'default_gps_dop', 45 ) # Compass if len(lla_fen_spl_comp) > 5: d['compass'] = lla_fen_spl_comp[5] # Image Height and Image Width if d['width'] <= 0 or not data.config['use_exif_size']: d['height'], d['width'] = data.load_image(image).shape[:2] d['camera'] = exif.camera_id(d) return d
def _extract_exif(self, image, data): # EXIF data in Image d = exif.extract_exif_from_file(data.open_image_file(image)) # Image Height and Image Width if d['width'] <= 0 or not data.config['use_exif_size']: d['height'], d['width'] = data.image_size(image) d['camera'] = exif.camera_id(d) return d
def _extract_exif(image, data): # EXIF data in Image d = exif.extract_exif_from_file(data.open_image_file(image)) # Image Height and Image Width if d["width"] <= 0 or not data.config["use_exif_size"]: d["height"], d["width"] = data.image_size(image) d["camera"] = exif.camera_id(d) return d
def _extract_exif(self, image, data): # EXIF data in Image d = exif.extract_exif_from_file(data.open_image_file(image)) # Image Height and Image Width if d['width'] <= 0 or not data.config['use_exif_size']: d['height'], d['width'] = data.load_image(image).shape[:2] d['camera'] = exif.camera_id(d) return d
def extract_metadata_image(image_path, opensfm_config): # EXIF data in Image d = exif.extract_exif_from_file(open_image_file(image_path)) # Override projection type if needed (Use auto projection type) # if opensfm_config['camera_projection_type'] != 'AUTO': # opensfm_config['projection_type'] = opensfm_config['camera_projection_type'].lower() # Image Height and Image Width if d['width'] <= 0 or not opensfm_config['use_exif_size']: d['height'], d['width'] = open_image_size(image_path) d['camera'] = exif.camera_id(d) return d
def _extract_exif(image, data: DataSetBase): with data.open_image_file(image) as fp: d = exif.extract_exif_from_file(fp, partial(data.image_size, image), data.config["use_exif_size"]) if data.config["unknown_camera_models_are_different"] and ( not d["model"] or d["model"] == "unknown"): d["model"] = f"unknown_{image}" if data.config.get("default_projection_type"): d["projection_type"] = data.config.get("default_projection_type") d["camera"] = exif.camera_id(d) return d
def _extract_exif(self, image, data): # EXIF data in Image d = exif.extract_exif_from_file(data.open_image_file(image)) # Override projection type if needed if data.config['camera_projection_type'] != 'AUTO': d['projection_type'] = data.config['camera_projection_type'].lower( ) # Image Height and Image Width if d['width'] <= 0 or not data.config['use_exif_size']: d['height'], d['width'] = data.image_size(image) d['camera'] = exif.camera_id(d) return d
def run(self, args): start = time.time() data = dataset.DataSet(args.dataset) exif_overrides = {} if data.exif_overrides_exists(): exif_overrides = data.load_exif_overrides() camera_models = {} for image in data.images(): logging.info('Extracting focal lengths for image {}'.format(image)) # EXIF data in Image d = exif.extract_exif_from_file(data.load_image(image)) # Image Height and Image Width if d['width'] <= 0 or not data.config['use_exif_size']: d['height'], d['width'] = data.image_as_array(image).shape[:2] d['camera'] = exif.camera_id(d) if image in exif_overrides: d.update(exif_overrides[image]) data.save_exif(image, d) if d['camera'] not in camera_models: camera = exif.camera_from_exif_metadata(d, data) camera_models[d['camera']] = camera # Override any camera specified in the camera models overrides file. if data.camera_models_overrides_exists(): overrides = data.load_camera_models_overrides() if "all" in overrides: for key in camera_models: camera_models[key] = copy.copy(overrides["all"]) camera_models[key].id = key else: for key, value in overrides.items(): camera_models[key] = value data.save_camera_models(camera_models) end = time.time() with open(data.profile_log(), 'a') as fout: fout.write('focal_from_exif: {0}\n'.format(end - start))
def _extract_exif(image, data): # EXIF data in Image with data.open_image_file(image) as fp: d = exif.extract_exif_from_file(fp) if data.config["unknown_camera_models_are_different"] and ( not d["model"] or d["model"] == "unknown"): d["model"] = f"unknown_{image}" if data.config.get("default_projection_type"): d["projection_type"] = data.config.get("default_projection_type") # Image Height and Image Width if d["width"] <= 0 or not data.config["use_exif_size"]: d["height"], d["width"] = data.image_size(image) d["camera"] = exif.camera_id(d) return d
def _extract_exif(image, data): # EXIF data in Image with data.open_image_file(image) as fp: d = exif.extract_exif_from_file(fp) if data.config["unknown_camera_models_are_different"] and ( not d["model"] or d["model"] == "unknown"): d["model"] = f"unknown_{image}" # TODO(pau): Undocumented hack. Replace with a cleaner solution. if data.config.get("use_brown_camera"): d["projection_type"] = "brown" # Image Height and Image Width if d["width"] <= 0 or not data.config["use_exif_size"]: d["height"], d["width"] = data.image_size(image) d["camera"] = exif.camera_id(d) return d