def save_local_mapping(import_path): local_mapping_filepath = os.path.join(os.path.dirname( import_path), import_path + "_mapillary_image_uuid_to_local_path_mapping.csv") total_files = uploader.get_total_file_list(import_path) local_mapping = [] for file in tqdm(total_files, desc="Reading image uuids"): image_file_uuid = None relative_path = file.lstrip(os.path.abspath(import_path)) log_rootpath = uploader.log_rootpath(file) image_description_json_path = os.path.join( log_rootpath, "mapillary_image_description.json") if os.path.isfile(image_description_json_path): image_description_json = processing.load_json( image_description_json_path) if "MAPPhotoUUID" in image_description_json: image_file_uuid = image_description_json["MAPPhotoUUID"] else: print( "Error, photo uuid not in mapillary_image_description.json log file.") else: image_exif = exif_read.ExifRead(file) image_description = json.loads( image_exif.extract_image_description()) if "MAPPhotoUUID" in image_description: image_file_uuid = str(image_description["MAPPhotoUUID"]) else: print("Warning, image {} EXIF does not contain mapillary image description and mapillary_image_description.json log file does not exist. Try to process the image using mapillary_tools.".format(file)) if image_file_uuid: local_mapping.append((relative_path, image_file_uuid)) return local_mapping
def get_points_from_exif(file_list, verbose=False): data = [] for file in file_list: point = () try: exif = exif_read.ExifRead(file) except: if verbose: print("Warning, EXIF could not be read for image {}.".format( file)) continue try: lon, lat = exif.extract_lon_lat() except: if verbose: print( "Warning {} image latitude or longitude tag not in EXIF.". format(file)) continue try: timestamp = exif.extract_capture_time() except: if verbose: print("Warning {} image capture time tag not in EXIF.".format( file)) continue if lon != None and lat != None and timestamp != None: point = point + (timestamp, lat, lon) else: continue try: altitude = exif.extract_altitude() point = point + (altitude, ) except: pass try: heading = exif.extract_direction() point = point + (heading, ) except: pass if point: data.append(point) return data