Beispiel #1
0
    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]))

    args = get_args()

    path = args.path
    cutoff_distance = args.cutoff_distance
    cutoff_time = args.cutoff_time
    skip_upload = args.skip_upload
    offset_angle = args.offset_angle
    interpolate_directions = args.interpolate_directions
    orientation = args.orientation
    project_key = get_project_key(args.project, args.project_key)
    verbose = args.verbose
    auto_done = args.auto_done
    add_file_name = args.add_file_name

    # Distance/Angle threshold for duplicate removal
    # NOTE: This might lead to removal of panorama sequences
    min_duplicate_distance = float(args.duplicate_distance)
    min_duplicate_angle = float(args.duplicate_angle)

    # Fetch authentication info
    try:
        MAPILLARY_USERNAME = args.user if args.user is not None else os.environ[
            'MAPILLARY_USERNAME']
        MAPILLARY_EMAIL = args.email if args.email is not None else os.environ[
            'MAPILLARY_EMAIL']
    script uses pieces of that.
    '''

    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]))

    args = get_args()

    path = args.path
    cutoff_distance = float(args.cutoff_distance)
    cutoff_time = float(args.cutoff_time)
    skip_upload = args.skip_upload
    offset_angle = float(args.offset_angle)
    interpolate_directions = args.interpolate_directions
    orientation = int(args.orientation)
    project_key = get_project_key(args.project)
    verbose = args.verbose
    auto_done = args.auto_done


    # Distance/Angle threshold for duplicate removal
    # NOTE: This might lead to removal of panorama sequences
    min_duplicate_distance = float(args.duplicate_distance)
    min_duplicate_angle = float(args.duplicate_angle)

    # Fetch authentication info
    try:
        MAPILLARY_USERNAME = args.user if args.user is not None else os.environ['MAPILLARY_USERNAME']
        MAPILLARY_EMAIL = args.email if args.email is not None else os.environ['MAPILLARY_EMAIL']
        MAPILLARY_SECRET_HASH = os.environ.get('MAPILLARY_SECRET_HASH', None)
        secret_hash = None
    project_key = args.project
    image_path = args.file_path
    json_path = args.json_path if args.json_path is not None else os.path.join(image_path, "mapillary_tag.json")
    output_path = args.output_path

    if not args.skip_authentication:
        # 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)
        project_key = get_project_key(project_key)
    else:
        MAPILLARY_USERNAME, MAPILLARY_EMAIL, MAPILLARY_PASSWORD = None, None, None
        upload_token = None

    with open(json_path, "rb") as f:
        metadata = json.loads(f.read())

    if output_path is not None and os.path.exists(output_path) is False:
        os.makedirs(output_path)
    else:
        output_path = ""

    images = os.listdir(image_path)
    for i, f in enumerate(images):
        if f.lower().endswith(('jpg', 'jpeg', 'png', 'tif', 'tiff', 'pgm', 'pnm', 'gif')):
Beispiel #4
0
        image_path, "mapillary_tag.json")
    output_path = args.output_path

    if not args.skip_authentication:
        # 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)
        project_key = get_project_key(project_key)
    else:
        MAPILLARY_USERNAME, MAPILLARY_EMAIL, MAPILLARY_PASSWORD = None, None, None
        upload_token = None

    with open(json_path, "rb") as f:
        metadata = json.loads(f.read())

    if output_path is not None and os.path.exists(output_path) is False:
        os.makedirs(output_path)
    else:
        output_path = ""

    images = os.listdir(image_path)
    for i, f in enumerate(images):
        if f.lower().endswith(
Beispiel #5
0
    # get env variables
    try:
        MAPILLARY_USERNAME = os.environ['MAPILLARY_USERNAME']
        MAPILLARY_EMAIL = os.environ['MAPILLARY_EMAIL']
        MAPILLARY_PASSWORD = os.environ['MAPILLARY_PASSWORD']

    except KeyError:
        sys.exit("You are missing one of the environment variables MAPILLARY_USERNAME, MAPILLARY_EMAIL or MAPILLARY_PASSWORD. These are required.")

    args = get_args()
    path = args.path
    project_name = args.project_name
    overwrite = args.overwrite
    print("Adding images in %s to project '%s'" % (path, project_name))

    project_key = get_project_key(project_name)

    if path.lower().endswith(".jpg"):
        file_list = [path]
    else:
        file_list = []
        for root, sub_folders, files in os.walk(path):
            file_list += [os.path.join(root, filename) for filename in files if filename.lower().endswith(".jpg")]

    num_file = len(file_list)
    for i, filepath in enumerate(file_list):
        exif = EXIF(filepath)
        description_ = exif.extract_image_description()
        exif_edit = ExifEdit(filepath)
        try:
            description_ = json.loads(description_)