コード例 #1
0
def get_pano_jpgs(lon_lat_list=[], saved_path=os.getcwd()):
    if len(lon_lat_list) == 0:
        lon_lat_list = [(-94.8696048, 29.2582707)]
    while len(lon_lat_list) > 0:
        lon, lat = lon_lat_list.pop(0)
        pano = GSV_pano(request_lon=lon,
                        request_lat=lat,
                        saved_path=saved_path)
        pano.get_panorama(zoom=5)
コード例 #2
0
def downoad_panoramas_from_json_list(json_file_list, saved_path, zoom=3):
    total_cnt = len(json_file_list)
    pre_dir = r'E:\USC_OneDrive\OneDrive - University of South Carolina\Research\sidewalk_wheelchair\DC_panoramas'
    start_time_all = time.perf_counter()
    while len(json_file_list) > 0:
        try:
            start_time = time.perf_counter()
            json_file = json_file_list.pop()
            basename = os.path.basename(json_file)[:-5] + "_4.jpg"
            new_name = os.path.join(saved_path, basename)
            if os.path.exists(new_name):
                print(f"{basename} exits, continue.")
                continue

            basename = os.path.basename(json_file)[:-5] + "_5.jpg"
            new_name = os.path.join(pre_dir, basename)
            if os.path.exists(new_name):
                print(f"{basename} exits, resample the current file.")
                img_pil = Image.open(new_name)
                w, h = img_pil.size
                w = int(w / 2)
                h = int(h / 2)
                img_pil = img_pil.resize((w, h))
                zoom4_pano_name = os.path.join(
                    saved_path,
                    os.path.basename(json_file)[:-5] + "_4.jpg")
                img_pil.save(zoom4_pano_name)
                continue
            pano1 = GSV_pano(json_file=json_file, saved_path=saved_path)
            pano1.get_panorama(zoom=zoom)
            total_time = (time.perf_counter() - start_time_all)
            efficency = total_time / (total_cnt - len(json_file_list))
            time_remain = efficency * len(json_file_list)
            print(
                f"Time spent (seconds): {time.perf_counter() - start_time:.1f}, time used: {utils.delta_time(total_time)} , time remain: {utils.delta_time(time_remain)}  \n"
            )

        except Exception as e:
            logging.error(
                "Error in downoad_panoramas_from_json_list(): %s, %s" %
                (e, json_file),
                exc_info=True)
            continue