def finalize_sequence_processing(sequence, final_file_list, final_directions, final_capture_times, import_path, verbose=False): for image, direction, capture_time in zip(final_file_list, final_directions, final_capture_times): mapillary_description = { 'MAPSequenceUUID': sequence, 'MAPCompassHeading': { "TrueHeading": direction, "MagneticHeading": direction }, "MAPCaptureTime": datetime.datetime.strftime(capture_time, "%Y_%m_%d_%H_%M_%S_%f")[:-3] } processing.create_and_log_process(image, "sequence_process", "success", mapillary_description, verbose=verbose)
def finalize_import_properties_process(image, import_path, orientation=None, device_make=None, device_model=None, GPS_accuracy=None, add_file_name=False, add_import_date=False, verbose=False, mapillary_description={}): # always check if there are any command line arguments passed, they will if orientation: mapillary_description["MAPOrientation"] = orientation if device_make: mapillary_description['MAPDeviceMake'] = device_make if device_model: mapillary_description['MAPDeviceModel'] = device_model if GPS_accuracy: mapillary_description['MAPGPSAccuracyMeters'] = float(GPS_accuracy) if add_file_name: add_meta_tag(mapillary_description, "strings", "original_file_name", image) if add_import_date: add_meta_tag(mapillary_description, "dates", "import_date", int(round(time.time() * 1000))) add_meta_tag(mapillary_description, "strings", "mapillary_tools_version", "0.1.4") processing.create_and_log_process(image, "import_meta_data_process", "success", mapillary_description, verbose)
def finalize_import_properties_process(image, import_path, orientation=None, device_make=None, device_model=None, GPS_accuracy=None, add_file_name=False, add_import_date=False, verbose=False, mapillary_description={}, custom_meta_data=None, camera_uuid=None, windows_path=False, exclude_import_path=False, exclude_path=None): # always check if there are any command line arguments passed, they will if orientation is not None: mapillary_description["MAPOrientation"] = orientation if device_make is not None: mapillary_description['MAPDeviceMake'] = device_make if device_model is not None: mapillary_description['MAPDeviceModel'] = device_model if GPS_accuracy is not None: mapillary_description['MAPGPSAccuracyMeters'] = float(GPS_accuracy) if camera_uuid is not None: mapillary_description['MAPCameraUUID'] = camera_uuid if add_file_name: image_path = image if exclude_import_path: image_path = image_path.replace( import_path, "").lstrip("\\").lstrip("/") elif exclude_path: image_path = image_path.replace( exclude_path, "").lstrip("\\").lstrip("/") if windows_path: image_path = image_path.replace("/", "\\") mapillary_description['MAPFilename'] = image_path if add_import_date: add_meta_tag(mapillary_description, "dates", "import_date", int(round(time.time() * 1000))) add_meta_tag(mapillary_description, "strings", "mapillary_tools_version", "0.5.0") if custom_meta_data: parse_and_add_custom_meta_tags(mapillary_description, custom_meta_data) processing.create_and_log_process(image, "import_meta_data_process", "success", mapillary_description, verbose)
def finalize_import_properties_process(image, import_path, orientation=None, device_make=None, device_model=None, GPS_accuracy=None, add_file_name=False, add_import_date=False, verbose=False, mapillary_description={}, custom_meta_data=None, camera_uuid=None, windows_path=False, exclude_import_path=False, exclude_path=None): # always check if there are any command line arguments passed, they will if orientation: mapillary_description["MAPOrientation"] = orientation if device_make: mapillary_description['MAPDeviceMake'] = device_make if device_model: mapillary_description['MAPDeviceModel'] = device_model if GPS_accuracy: mapillary_description['MAPGPSAccuracyMeters'] = float(GPS_accuracy) if camera_uuid: mapillary_description['MAPCameraUUID'] = camera_uuid if add_file_name: image_path = image if exclude_import_path: image_path = image_path.replace(import_path, "").lstrip("\\").lstrip("/") elif exclude_path: image_path = image_path.replace(exclude_path, "").lstrip("\\").lstrip("/") if windows_path: image_path = image_path.replace("/", "\\") mapillary_description['MAPFilename'] = image_path if add_import_date: add_meta_tag(mapillary_description, "dates", "import_date", int(round(time.time() * 1000))) add_meta_tag(mapillary_description, "strings", "mapillary_tools_version", "0.4.2") if custom_meta_data: parse_and_add_custom_meta_tags(mapillary_description, custom_meta_data) processing.create_and_log_process(image, "import_meta_data_process", "success", mapillary_description, verbose)
def insert_MAPJson(import_path, master_upload=False, verbose=False, rerun=False, skip_subfolders=False, skip_EXIF_insert=False): # basic check for all import_path = os.path.abspath(import_path) if not os.path.isdir(import_path): print("Error, import directory " + import_path + " doesnt not exist, exiting...") sys.exit() # get list of file to process process_file_list = processing.get_process_file_list(import_path, "mapillary_image_description", rerun, verbose, skip_subfolders) if not len(process_file_list): print("No images to run process finalization") print("If the images have already been processed and not yet uploaded, they can be processed again, by passing the argument --rerun") for image in process_file_list: # check the processing logs log_root = uploader.log_rootpath(import_path, image) duplicate_path = os.path.join(log_root, "duplicate") if os.path.isfile(duplicate_path): continue final_mapillary_image_description = processing.get_final_mapillary_image_description(log_root, image, master_upload, verbose, skip_EXIF_insert) processing.create_and_log_process(image, import_path, "mapillary_image_description", "success", final_mapillary_image_description, verbose=verbose)
def insert_MAPJson(import_path, master_upload=False, verbose=False, rerun=False, skip_subfolders=False, skip_EXIF_insert=False, keep_original=False): # basic check for all import_path = os.path.abspath(import_path) if not os.path.isdir(import_path): print("Error, import directory " + import_path + " doesnt not exist, exiting...") sys.exit() # get list of file to process process_file_list = processing.get_process_file_list( import_path, "mapillary_image_description", rerun, verbose, skip_subfolders) if not len(process_file_list): print("No images to run process finalization") print( "If the images have already been processed and not yet uploaded, they can be processed again, by passing the argument --rerun" ) for image in process_file_list: # check the processing logs log_root = uploader.log_rootpath(image) duplicate_path = os.path.join(log_root, "duplicate") if os.path.isfile(duplicate_path): continue final_mapillary_image_description = processing.get_final_mapillary_image_description( log_root, image, master_upload, verbose, skip_EXIF_insert, keep_original) processing.create_and_log_process(image, "mapillary_image_description", "success", final_mapillary_image_description, verbose=verbose)
def finalize_import_properties_process(image, import_path, orientation=None, device_make=None, device_model=None, GPS_accuracy=None, add_file_name=False, add_import_date=False, verbose=False, mapillary_description={}): # always check if there are any command line arguments passed, they will if orientation: mapillary_description["MAPOrientation"] = orientation if device_make: mapillary_description['MAPDeviceMake'] = device_make if device_model: mapillary_description['MAPDeviceModel'] = device_model if GPS_accuracy: mapillary_description['MAPGPSAccuracyMeters'] = float(GPS_accuracy) if add_file_name: add_meta_tag(mapillary_description, "strings", "original_file_name", image) if add_import_date: add_meta_tag(mapillary_description, "dates", "import_date", int(round(time.time() * 1000))) add_meta_tag(mapillary_description, "strings", "mapillary_tools_version", "0.0.1") processing.create_and_log_process(image, import_path, "import_meta_data_process", "success", mapillary_description, verbose)
def finalize_sequence_processing(sequence, final_file_list, final_directions, final_capture_times, import_path, verbose=False): for image, direction, capture_time in tqdm(zip(final_file_list, final_directions, final_capture_times), desc="Finalizing sequence process"): mapillary_description = { 'MAPSequenceUUID': sequence, 'MAPCompassHeading': { "TrueHeading": direction, "MagneticHeading": direction }, "MAPCaptureTime": datetime.datetime.strftime( capture_time, "%Y_%m_%d_%H_%M_%S_%f")[:-3] } processing.create_and_log_process(image, "sequence_process", "success", mapillary_description, verbose=verbose)
def process_upload_params(import_path, user_name, master_upload=False, verbose=False, rerun=False, skip_subfolders=False): # basic check for all import_path = os.path.abspath(import_path) if not os.path.isdir(import_path): print("Error, import directory " + import_path + " doesnt not exist, exiting...") sys.exit() # get list of file to process process_file_list = processing.get_process_file_list( import_path, "upload_params_process", rerun, verbose, skip_subfolders) if not len(process_file_list): print("No images to run upload params process") print( "If the images have already been processed and not yet uploaded, they can be processed again, by passing the argument --rerun" ) # sanity checks if not user_name: print("Error, must provide a valid user name, exiting...") processing.create_and_log_process_in_list( process_file_list, "upload_params_process" "failed", verbose) return if not master_upload: try: credentials = uploader.authenticate_user(user_name) except: print("Error, user authentication failed for user " + user_name) processing.create_and_log_process_in_list( process_file_list, "upload_params_process" "failed", verbose) return if credentials == None or "user_upload_token" not in credentials or "user_permission_hash" not in credentials or "user_signature_hash" not in credentials: print("Error, user authentication failed for user " + user_name) processing.create_and_log_process_in_list( process_file_list, "upload_params_process" "failed", verbose) return user_upload_token = credentials["user_upload_token"] user_permission_hash = credentials["user_permission_hash"] user_signature_hash = credentials["user_signature_hash"] user_key = credentials["MAPSettingsUserKey"] for image in process_file_list: # check the status of the sequence processing log_root = uploader.log_rootpath(image) duplicate_flag_path = os.path.join(log_root, "duplicate") upload_params_path = os.path.join(log_root, "upload_params_process.json") if os.path.isfile(upload_params_path): os.remove(upload_params_path) if os.path.isfile(duplicate_flag_path) or master_upload: continue upload_params_properties = processing.get_upload_param_properties( log_root, image, user_name, user_upload_token, user_permission_hash, user_signature_hash, user_key, verbose) processing.create_and_log_process(image, "upload_params_process", "success", upload_params_properties, verbose=verbose) # flag manual upload log_manual_upload = os.path.join(log_root, "manual_upload") open(log_manual_upload, 'a').close()
def insert_MAPJson(import_path, master_upload=False, verbose=False, rerun=False, skip_subfolders=False, skip_EXIF_insert=False, keep_original=False, video_file=None): # sanity check if video file is passed if video_file and not (os.path.isdir(video_file) or os.path.isfile(video_file)): print("Error, video path " + video_file + " does not exist, exiting...") sys.exit(1) # in case of video processing, adjust the import path if video_file: # set sampling path video_sampling_path = processing.sampled_video_frames_rootpath( video_file) import_path = os.path.join( os.path.abspath(import_path), video_sampling_path) if import_path else os.path.join( os.path.dirname(video_file), video_sampling_path) # basic check for all if not import_path or not os.path.isdir(import_path): print("Error, import directory " + import_path + " does not exist, exiting...") sys.exit(1) # get list of file to process process_file_list = processing.get_process_file_list( import_path, "mapillary_image_description", rerun, verbose, skip_subfolders) if not len(process_file_list): print("No images to run process finalization") print( "If the images have already been processed and not yet uploaded, they can be processed again, by passing the argument --rerun" ) progress_count = 0 for image in process_file_list: progress_count += 1 if verbose: if (progress_count % 50) == 0: sys.stdout.write(".") if (progress_count % 5000) == 0: print("") # check the processing logs log_root = uploader.log_rootpath(image) duplicate_path = os.path.join(log_root, "duplicate") if os.path.isfile(duplicate_path): continue final_mapillary_image_description = processing.get_final_mapillary_image_description( log_root, image, master_upload, verbose, skip_EXIF_insert, keep_original) processing.create_and_log_process(image, "mapillary_image_description", "success", final_mapillary_image_description, verbose=verbose) print("Sub process finished")
def insert_MAPJson(import_path, master_upload=False, verbose=False, rerun=False, skip_subfolders=False, skip_EXIF_insert=False, keep_original=False, video_import_path=None, overwrite_all_EXIF_tags=False, overwrite_EXIF_time_tag=False, overwrite_EXIF_gps_tag=False, overwrite_EXIF_direction_tag=False, overwrite_EXIF_orientation_tag=False): # sanity check if video file is passed if video_import_path and not os.path.isdir(video_import_path): print("Error, video path " + video_import_path + " does not exist, exiting...") sys.exit(1) # in case of video processing, adjust the import path if video_import_path: # set sampling path video_sampling_path = "mapillary_sampled_video_frames" import_path = os.path.join( os.path.abspath(import_path), video_sampling_path) if import_path else os.path.join( os.path.abspath(video_import_path), video_sampling_path) # basic check for all if not import_path or not os.path.isdir(import_path): print("Error, import directory " + import_path + " does not exist, exiting...") sys.exit(1) # get list of file to process process_file_list = processing.get_process_file_list( import_path, "mapillary_image_description", rerun, verbose, skip_subfolders) if not len(process_file_list): print("No images to run process finalization") print( "If the images have already been processed and not yet uploaded, they can be processed again, by passing the argument --rerun" ) for image in tqdm( process_file_list, desc="Inserting mapillary image description in image EXIF"): # check the processing logs log_root = uploader.log_rootpath(image) duplicate_path = os.path.join(log_root, "duplicate") if os.path.isfile(duplicate_path): continue final_mapillary_image_description = processing.get_final_mapillary_image_description( log_root, image, master_upload, verbose, skip_EXIF_insert, keep_original, overwrite_all_EXIF_tags, overwrite_EXIF_time_tag, overwrite_EXIF_gps_tag, overwrite_EXIF_direction_tag, overwrite_EXIF_orientation_tag) processing.create_and_log_process(image, "mapillary_image_description", "success", final_mapillary_image_description, verbose=verbose) print("Sub process ended")
def process_upload_params(import_path, user_name, master_upload=False, verbose=False, rerun=False, skip_subfolders=False, video_import_path=None): # sanity check if video file is passed if video_import_path and not os.path.isdir( video_import_path) and not os.path.isfile(video_import_path): print("Error, video path " + video_import_path + " does not exist, exiting...") sys.exit(1) # in case of video processing, adjust the import path if video_import_path: # set sampling path video_sampling_path = "mapillary_sampled_video_frames" video_dirname = video_import_path if os.path.isdir( video_import_path) else os.path.dirname(video_import_path) import_path = os.path.join( os.path.abspath(import_path), video_sampling_path) if import_path else os.path.join( os.path.abspath(video_dirname), video_sampling_path) # basic check for all if not import_path or not os.path.isdir(import_path): print_error("Error, import directory " + import_path + " does not exist, exiting...") sys.exit(1) # get list of file to process process_file_list = processing.get_process_file_list( import_path, "upload_params_process", rerun, verbose, skip_subfolders) if not len(process_file_list): print("No images to run upload params process") print( "If the images have already been processed and not yet uploaded, they can be processed again, by passing the argument --rerun" ) # sanity checks if not user_name: print_error("Error, must provide a valid user name, exiting...") processing.create_and_log_process_in_list( process_file_list, "upload_params_process" "failed", verbose) sys.exit(1) if not master_upload: try: credentials = uploader.authenticate_user(user_name) except: print_error("Error, user authentication failed for user " + user_name) processing.create_and_log_process_in_list( process_file_list, "upload_params_process" "failed", verbose) sys.exit(1) if credentials == None or "user_upload_token" not in credentials or "user_permission_hash" not in credentials or "user_signature_hash" not in credentials: print_error("Error, user authentication failed for user " + user_name) processing.create_and_log_process_in_list( process_file_list, "upload_params_process" "failed", verbose) sys.exit(1) user_upload_token = credentials["user_upload_token"] user_permission_hash = credentials["user_permission_hash"] user_signature_hash = credentials["user_signature_hash"] user_key = credentials["MAPSettingsUserKey"] for image in tqdm(process_file_list, desc="Processing image upload parameters"): # check the status of the sequence processing log_root = uploader.log_rootpath(image) duplicate_flag_path = os.path.join(log_root, "duplicate") upload_params_path = os.path.join(log_root, "upload_params_process.json") if os.path.isfile(upload_params_path): os.remove(upload_params_path) if os.path.isfile(duplicate_flag_path) or master_upload: continue upload_params_properties = processing.get_upload_param_properties( log_root, image, user_name, user_upload_token, user_permission_hash, user_signature_hash, user_key, verbose) processing.create_and_log_process(image, "upload_params_process", "success", upload_params_properties, verbose=verbose) # flag manual upload log_manual_upload = os.path.join(log_root, "manual_upload") open(log_manual_upload, 'a').close() print("Sub process ended")
def insert_MAPJson(import_path, master_upload=False, verbose=False, rerun=False, skip_subfolders=False, skip_EXIF_insert=False, keep_original=False, video_import_path=None, overwrite_all_EXIF_tags=False, overwrite_EXIF_time_tag=False, overwrite_EXIF_gps_tag=False, overwrite_EXIF_direction_tag=False, overwrite_EXIF_orientation_tag=False): # sanity check if video file is passed if video_import_path and not os.path.isdir(video_import_path) and not os.path.isfile(video_import_path): print("Error, video path " + video_import_path + " does not exist, exiting...") sys.exit(1) # in case of video processing, adjust the import path if video_import_path: # set sampling path video_sampling_path = "mapillary_sampled_video_frames" video_dirname = video_import_path if os.path.isdir( video_import_path) else os.path.dirname(video_import_path) import_path = os.path.join(os.path.abspath(import_path), video_sampling_path) if import_path else os.path.join( os.path.abspath(video_dirname), video_sampling_path) # basic check for all if not import_path or not os.path.isdir(import_path): print_error("Error, import directory " + import_path + " does not exist, exiting...") sys.exit(1) # get list of file to process process_file_list = processing.get_process_file_list(import_path, "mapillary_image_description", rerun, verbose, skip_subfolders) if not len(process_file_list): print("No images to run process finalization") print("If the images have already been processed and not yet uploaded, they can be processed again, by passing the argument --rerun") for image in tqdm(process_file_list, desc="Inserting mapillary image description in image EXIF"): # check the processing logs log_root = uploader.log_rootpath(image) duplicate_path = os.path.join(log_root, "duplicate") if os.path.isfile(duplicate_path): continue final_mapillary_image_description = processing.get_final_mapillary_image_description(log_root, image, master_upload, verbose, skip_EXIF_insert, keep_original, overwrite_all_EXIF_tags, overwrite_EXIF_time_tag, overwrite_EXIF_gps_tag, overwrite_EXIF_direction_tag, overwrite_EXIF_orientation_tag) processing.create_and_log_process(image, "mapillary_image_description", "success", final_mapillary_image_description, verbose=verbose) print("Sub process ended")
def process_upload_params(import_path, user_name, master_upload=False, verbose=False, rerun=False, skip_subfolders=False, video_import_path=None): # sanity check if video file is passed if video_import_path and not os.path.isdir(video_import_path) and not os.path.isfile(video_import_path): print("Error, video path " + video_import_path + " does not exist, exiting...") sys.exit(1) # in case of video processing, adjust the import path if video_import_path: # set sampling path video_sampling_path = "mapillary_sampled_video_frames" video_dirname = video_import_path if os.path.isdir( video_import_path) else os.path.dirname(video_import_path) import_path = os.path.join(os.path.abspath(import_path), video_sampling_path) if import_path else os.path.join( os.path.abspath(video_dirname), video_sampling_path) # basic check for all if not import_path or not os.path.isdir(import_path): print_error("Error, import directory " + import_path + " does not exist, exiting...") sys.exit(1) # get list of file to process process_file_list = processing.get_process_file_list(import_path, "upload_params_process", rerun, verbose, skip_subfolders) if not len(process_file_list): print("No images to run upload params process") print("If the images have already been processed and not yet uploaded, they can be processed again, by passing the argument --rerun") # sanity checks if not user_name: print_error("Error, must provide a valid user name, exiting...") processing.create_and_log_process_in_list(process_file_list, "upload_params_process" "failed", verbose) sys.exit(1) if not master_upload: try: credentials = uploader.authenticate_user(user_name) except: print_error( "Error, user authentication failed for user " + user_name) processing.create_and_log_process_in_list(process_file_list, "upload_params_process" "failed", verbose) sys.exit(1) if credentials == None or "user_upload_token" not in credentials or "user_permission_hash" not in credentials or "user_signature_hash" not in credentials: print_error( "Error, user authentication failed for user " + user_name) processing.create_and_log_process_in_list(process_file_list, "upload_params_process" "failed", verbose) sys.exit(1) user_upload_token = credentials["user_upload_token"] user_permission_hash = credentials["user_permission_hash"] user_signature_hash = credentials["user_signature_hash"] user_key = credentials["MAPSettingsUserKey"] for image in tqdm(process_file_list, desc="Processing image upload parameters"): # check the status of the sequence processing log_root = uploader.log_rootpath(image) duplicate_flag_path = os.path.join(log_root, "duplicate") upload_params_path = os.path.join( log_root, "upload_params_process.json") if os.path.isfile(upload_params_path): os.remove(upload_params_path) if os.path.isfile(duplicate_flag_path) or master_upload: continue upload_params_properties = processing.get_upload_param_properties(log_root, image, user_name, user_upload_token, user_permission_hash, user_signature_hash, user_key, verbose) processing.create_and_log_process(image, "upload_params_process", "success", upload_params_properties, verbose=verbose) # flag manual upload log_manual_upload = os.path.join( log_root, "manual_upload") open(log_manual_upload, 'a').close() print("Sub process ended")
def process_upload_params(import_path, user_name, master_upload=False, verbose=False, rerun=False, skip_subfolders=False): # basic check for all import_path = os.path.abspath(import_path) if not os.path.isdir(import_path): print("Error, import directory " + import_path + " doesnt not exist, exiting...") sys.exit() # get list of file to process process_file_list = processing.get_process_file_list(import_path, "upload_params_process", rerun, verbose, skip_subfolders) if not len(process_file_list): print("No images to run upload params process") print("If the images have already been processed and not yet uploaded, they can be processed again, by passing the argument --rerun") # sanity checks if not user_name: print("Error, must provide a valid user name, exiting...") processing.create_and_log_process_in_list(process_file_list, import_path, "upload_params_process" "failed", verbose) return if not master_upload: try: credentials = uploader.authenticate_user(user_name) except: print("Error, user authentication failed for user " + user_name) processing.create_and_log_process_in_list(process_file_list, import_path, "upload_params_process" "failed", verbose) return if credentials == None or "user_upload_token" not in credentials or "user_permission_hash" not in credentials or "user_signature_hash" not in credentials: print("Error, user authentication failed for user " + user_name) processing.create_and_log_process_in_list(process_file_list, import_path, "upload_params_process" "failed", verbose) return user_upload_token = credentials["user_upload_token"] user_permission_hash = credentials["user_permission_hash"] user_signature_hash = credentials["user_signature_hash"] user_key = credentials["MAPSettingsUserKey"] for image in process_file_list: # check the status of the sequence processing log_root = uploader.log_rootpath(import_path, image) duplicate_flag_path = os.path.join(log_root, "duplicate") upload_params_path = os.path.join( log_root, "upload_params_process.json") if os.path.isfile(upload_params_path): os.remove(upload_params_path) if os.path.isfile(duplicate_flag_path) or master_upload: continue upload_params_properties = processing.get_upload_param_properties(log_root, image, user_name, user_upload_token, user_permission_hash, user_signature_hash, user_key, verbose) processing.create_and_log_process(image, import_path, "upload_params_process", "success", upload_params_properties, verbose=verbose) # flag manual upload log_manual_upload = os.path.join( log_root, "manual_upload") open(log_manual_upload, 'a').close()