Esempio n. 1
0
            sequence_ids[im] = sequence_uuid

    # Get authentication info
    email, upload_token, secret_hash, upload_url = uploader.get_full_authentication_info(
        email=args.email)

    # Encode Mapillary meta
    print("Adding Mapillary tags ...")
    for p in meta["photos"]:
        photo_file = p["photo_file_path"]
        if photo_file in sequence_ids:
            external_properties = {"photo_id": p["photo_id"]}
            create_mapillary_description(
                photo_file,
                args.user,
                email,
                upload_token,
                sequence_ids[photo_file],
                secret_hash=secret_hash,
                external_properties=external_properties,
                verbose=False)

    print "".join([
        '\nExport completed:' +
        '\nPhotos with no timestamp : {}'.format(num_missing_date),
        '\nPhotos with exif error : {}'.format(num_exif_error),
        '\nYou can now review your photos at "{}".'.format(image_path) +
        '\nMove the photos you want to skip to another folder.' +
        '\nUpload the photos by running "python upload.py {}"'.format(
            image_path)
    ])
Esempio n. 2
0
                for i, filename in enumerate(s.file_list):
                    if is_image(filename):
                        filepath = os.path.join(filename)

                        # Determine whether use interpolated direction or not
                        if interpolate_directions and len(s.file_list) > 1:
                            bearing = directions[filepath]
                        else:
                            bearing = None

                        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, bearing, offset_angle,
                                    orientation)
                            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))
                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))
                    if is_image(filename):
                        filepath = os.path.join(filename)

                        # Determine whether use interpolated direction or not
                        if interpolate_directions and len(s.file_list) > 1:
                            bearing = directions[filepath]
                        else:
                            bearing = None

                        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,
                                                             bearing,
                                                             orientation)
                            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))
Esempio n. 5
0
                        if interpolate_directions and len(s.file_list) > 1:
                            bearing = directions[filepath]

                        # Add original file name to EXIF
                        if add_file_name:
                            external_properties = {
                                "file_name": os.path.abspath(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, MAPILLARY_USERKEY,
                                    upload_token, sequence_uuid, bearing,
                                    offset_angle, timestamp, orientation,
                                    project_key, secret_hash,
                                    external_properties)
                            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:
if __name__ == '__main__':
    '''
    Use from command line as: python add_mapillary_tag_from_exif.py root_path [sequence_uuid]
    '''

    # Fetch authentication 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 or len(args) > 3:
        sys.exit("Usage: python %s root_path [sequence_id]" % args[0])

    path = args[1]

    for root, sub_folders, files in os.walk(path):
        sequence_uuid = args[2] if len(args) == 3 else 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))
                    if is_image(filename):
                        filepath = os.path.join(filename)

                        # Determine whether use interpolated direction or not
                        if interpolate_directions and len(s.file_list) > 1:
                            bearing = directions[filepath]
                        else:
                            bearing = None
                        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,
                                                             bearing,
                                                             offset_angle,
                                                             orientation,
                                                             project_key,
                                                             secret_hash)
                            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))
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 or len(args) > 3:
        sys.exit("Usage: python %s root_path [sequence_id]" % args[0])

    path = args[1]

    for root, sub_folders, files in os.walk(path):
        sequence_uuid = args[2] if len(args) == 3 else 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))
                # 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)
    sequence_ids = {}
    for s in sequences:
        sequence_uuid = str(uuid.uuid4())
        for im in s:
            sequence_ids[im] = sequence_uuid

    # Get authentication info
    email, upload_token, secret_hash, upload_url = uploader.get_full_authentication_info(email=args.email)

    # Encode Mapillary meta
    print("Adding Mapillary tags ...")
    for p in meta["photos"]:
        photo_file = p["photo_file_path"]
        if photo_file in sequence_ids:
            external_properties = {
                "photo_id": p["photo_id"]
            }
            create_mapillary_description(
                photo_file, args.user, email,
                upload_token, sequence_ids[photo_file],
                secret_hash=secret_hash,
                external_properties=external_properties,
                verbose=False
            )

    print "".join(['\nExport completed:' +
          '\nPhotos with no timestamp : {}'.format(num_missing_date),
          '\nPhotos with exif error : {}'.format(num_exif_error),
          '\nYou can now review your photos at "{}".'.format(image_path) +
          '\nMove the photos you want to skip to another folder.' +
          '\nUpload the photos by running "python upload.py {}"'.format(image_path)])