# Add a sequence uuid per sub-folder if len(s.file_list) > 0: sequence_uuid = uuid.uuid4() print(" sequence uuid: {}".format(sequence_uuid)) file_list = [] for i, filename in enumerate(s.file_list): if is_image(filename): filepath = os.path.join(filename) if verify_exif(filepath): if not retry_upload: # skip creating new sequence id for failed images create_mapillary_description(filepath, MAPILLARY_USERNAME, MAPILLARY_EMAIL, upload_token, sequence_uuid, directions[filepath]) file_list.append(filepath) else: missing_groups.append(filepath) else: print " Ignoring {0}".format(os.path.join(root,filename)) lib.io.progress(i, len(s.file_list), 'Adding Mapillary tags') count = len(file_list) if count > 0: sequence_list[str(sequence_uuid)] = file_list else: print(" Skipping images in {}".format(root)) write_processing_log(sequence_list, path)
if __name__ == '__main__': ''' Use from command line as: python add_mapillary_tag_from_exif.py root_path [sequence_uuid] ''' # Fetch authetication info from env info = get_authentication_info() if info is not None: MAPILLARY_USERNAME, MAPILLARY_EMAIL, MAPILLARY_PASSWORD = info else: print("You are missing one of the environment variables MAPILLARY_USERNAME, MAPILLARY_EMAIL or MAPILLARY_PASSWORD. These are required.") sys.exit() upload_token = get_upload_token(MAPILLARY_EMAIL, MAPILLARY_PASSWORD) args = sys.argv if len(args) != 2: print("Usage: python add_mapillary_tag_from_exif.py root_path") raise IOError("Bad input parameters.") path = args[1] for root, sub_folders, files in os.walk(path): sequence_uuid = uuid.uuid4() print("Processing folder {0}, {1} files, sequence_id {2}.".format(root, len(files), sequence_uuid)) for file in files: if file.lower().endswith(('jpg', 'jpeg', 'png', 'tif', 'tiff', 'pgm', 'pnm', 'gif')): create_mapillary_description(os.path.join(root,file), MAPILLARY_USERNAME, MAPILLARY_EMAIL, upload_token, sequence_uuid) else: print "Ignoring {0}".format(os.path.join(root,file))
directions = s.interpolate_direction() # Add a sequence uuid per sub-folder if len(s.file_list) > 0: sequence_uuid = uuid.uuid4() print(" sequence uuid: {}".format(sequence_uuid)) file_list = [] for i, filename in enumerate(s.file_list): if is_image(filename): filepath = os.path.join(filename) if verify_exif(filepath): if not retry_upload: # skip creating new sequence id for failed images create_mapillary_description( filepath, MAPILLARY_USERNAME, MAPILLARY_EMAIL, upload_token, sequence_uuid, directions[filepath]) file_list.append(filepath) else: missing_groups.append(filepath) else: print " Ignoring {0}".format( os.path.join(root, filename)) lib.io.progress(i, len(s.file_list), 'Adding Mapillary tags') count = len(file_list) if count > 0: sequence_list[str(sequence_uuid)] = file_list else: print(" Skipping images in {}".format(root))