def test_run(image_path): ''' Test run for images ''' s = Sequence(image_path, check_exif=False) file_list = s.get_file_list(image_path) num_image = len(file_list) t1 = datetime.datetime.strptime('2000_09_03_12_00_00', '%Y_%m_%d_%H_%M_%S') t2 = datetime.datetime.strptime('2000_09_03_12_30_00', '%Y_%m_%d_%H_%M_%S') p1 = point(0.5, 0.5, 0.2, t1, num_image-2) p2 = point(0.55, 0.55, 0.0, t2, 0) inter_points = interpolate_with_anchors([p1, p2], angle_offset=-90.0) save_path = os.path.join(image_path, 'processed') lib.io.mkdir_p(save_path) assert(len(inter_points)==len(file_list)) for f, p in zip(file_list, inter_points): meta = ExifEdit(f) meta.add_lat_lon(p[1], p[2]) meta.add_altitude(p[3]) meta.add_date_time_original(p[0]) meta.add_orientation(1) meta.add_direction(p[4]) meta.write()
if __name__ == '__main__': ''' Use from command line as: python upload.py path ''' if sys.version_info >= (3, 0): raise IOError("Incompatible Python version. This script requires Python 2.x, you are using {0}.".format( sys.version_info[:2])) parser = argparse.ArgumentParser( description='Upload photos taken with Mapillary apps') parser.add_argument('path', help='path to your photos') parser.add_argument('--upload_subfolders', help='option to upload subfolders', action='store_true') args = parser.parse_args() path = args.path skip_subfolders = not args.upload_subfolders s = Sequence(path, skip_folders=[ 'success', 'duplicates'], skip_subfolders=skip_subfolders, check_exif=False) num_image_file = len(s.file_list) file_list = [f for f in s.file_list if verify_mapillary_tag(f)] print("Uploading {} images with valid mapillary tags (Skipping {})".format( len(file_list), num_image_file - len(file_list))) upload_file_list(file_list) print("Done uploading {} images.".format(len(file_list)))
MAPILLARY_EMAIL = os.environ['MAPILLARY_EMAIL'] MAPILLARY_PASSWORD = os.environ['MAPILLARY_PASSWORD'] MAPILLARY_PERMISSION_HASH = os.environ['MAPILLARY_PERMISSION_HASH'] MAPILLARY_SIGNATURE_HASH = os.environ['MAPILLARY_SIGNATURE_HASH'] except KeyError: print( "You are missing one of the environment variables MAPILLARY_USERNAME, MAPILLARY_EMAIL, MAPILLARY_PASSWORD, MAPILLARY_PERMISSION_HASH or MAPILLARY_SIGNATURE_HASH. These are required." ) sys.exit() upload_token = get_upload_token(MAPILLARY_EMAIL, MAPILLARY_PASSWORD) # Check whether the directory has been processed before logs = read_log(path) retry_upload = False if logs is not None: s = Sequence(path) total_failed = len([f for f in s.file_list if 'failed' in f]) print("This folder has been processed before. See summary below: \n{}". format(logs)) if total_failed: print("There are {} failed images.".format(total_failed)) proceed = raw_input("Retry uploading failed images? [y/n]: ") if proceed in ["y", "Y", "yes", "Yes"]: retry_upload = True print("Start uploading failed images ...") elif proceed in ["n", "N", "no", "No"]: retry_upload = False print("Aborted. No retry on failed uploads") sys.exit() else: print('Please answer y or n. Try again.')
action='store_true', dest='timestamp', help='keep original timestamp of image file') parser.add_argument( '--backup', action='store_true', dest='backup', help='store backup of overwritten values in Mapillary JSON') args = parser.parse_args() if args.orientation is not None: exifOrientation = format_orientation(args.orientation) s = Sequence(args.path) if args.interpolate: bearings = s.interpolate_direction() for filename in s.get_file_list(args.path): stat = os.stat(filename) exifRead = EXIF(filename) mapillaryTag = json.loads(exifRead.extract_image_description()) if args.interpolate: bearing = bearings[filename] else: bearing = exifRead.extract_direction() if args.offset: bearing = offset_bearing(bearing, args.offset)
sys.exit() # generate a sequence UUID sequence_id = uuid.uuid4() # S3 bucket s3_bucket = MAPILLARY_USERNAME+"/"+str(sequence_id)+"/" # set upload parameters params = {"url": MAPILLARY_UPLOAD_URL, "key": s3_bucket, "permission": MAPILLARY_PERMISSION_HASH, "signature": MAPILLARY_SIGNATURE_HASH, "move_files": MOVE_FILES} # get the list of images in the folder # Caution: all nested folders will be merged into one sequence! s = Sequence(path, skip_folders=['success', 'duplicates'], skip_subfolders=skip_subfolders) if len(s.file_list) == 0: print('No images in the folder or all images have all ready been uploaded to Mapillary') print('Note: If upload fails mid-sequence due to connection failure or similar, you should manually push the images to the server at http://www.mapillary.com/map/upload/im/ and pressing "push to Mapillary".') sys.exit() print("Uploading sequence {0}.".format(sequence_id)) # check mapillary tag and required exif file_list = [] for filepath in s.file_list: mapillary_tag_exists = EXIF(filepath).mapillary_tag_exists() if mapillary_tag_exists: print("File {} contains Mapillary EXIF tags, use upload.py instead.".format(filepath))
The default cutoff distance is 500 meters. [cutoff_time] If you used a camera with a 2s timer and took lots of sequences, running this script with a 3s cutoff will produce nice subfolders, one for each sequence. If no cutoff time is given, one will be estimated based on the median time difference. ''' if __name__ == '__main__': ''' Use from command line as: python sequence_split.py path [cutoff_time] [cutoff_distance] @params path: path to the photos @params cutoff_time: cutoff time in seconds @params cutoff_distance: cutoff distance in meters ''' if len(sys.argv) > 4 or len(sys.argv) < 2: print("Usage: python sequence_split.py path [cutoff_time] [cutoff_distance] ") raise IOError("Bad input parameters.") path = sys.argv[1] cutoff_time = None if len(sys.argv)<3 else float(sys.argv[2]) cutoff_distance = 500 if len(sys.argv)<4 else float(sys.argv[3]) s = Sequence(path) groups = s.split(cutoff_distance=cutoff_distance, cutoff_time=cutoff_time)
''' if __name__ == '__main__': ''' Use from command line as: python upload.py path ''' if sys.version_info >= (3, 0): raise IOError( "Incompatible Python version. This script requires Python 2.x, you are using {0}." .format(sys.version_info[:2])) if len(sys.argv) > 2: print("Usage: python upload.py path") raise IOError("Bad input parameters.") path = sys.argv[1] s = Sequence(path, skip_folders=['success'], check_exif=False) num_image_file = len(s.file_list) file_list = [f for f in s.file_list if verify_mapillary_tag(f)] print("Uploading {} images with valid mapillary tags (Skipping {})".format( len(file_list), num_image_file - len(file_list))) upload_file_list(file_list) print("Done uploading {} images.".format(len(file_list)))