Esempio n. 1
0
def test_get_depthmap():
    saved_path = os.getcwd()

    print(Image.__version__)

    lon = -77.072465
    lat = 38.985399

    pano1 = GSV_pano(request_lon=lon,
                     request_lat=lat,
                     crs_local=6487,
                     saved_path=saved_path)
    pano1.get_depthmap(zoom=0, saved_path=saved_path)
    pano1.get_DOM(resolution=0.1)
Esempio n. 2
0
def get_DOM(pid_id, seg_files, saved_path, resolution):
    seg_dir = os.path.dirname(seg_files[0])
    total_cnt = len(seg_files)
    start_time_all = time.perf_counter()
    while len(seg_files) > 0:
        seg_file = seg_files.pop()
        start_time = time.perf_counter()
        try:
            print("Process No.", pid_id, "is processing: ",
                  total_cnt - len(seg_files), seg_file)
            panoId = os.path.basename(seg_file)[:-4]

            # pano1 = GSV_pano(panoId=panoId, crs_local=6487, saved_path=saved_path)

            new_name = os.path.join(saved_path,
                                    panoId + f"_DOM_{resolution:.2f}.tif")
            is_processed = os.path.exists(new_name)

            Links = pano1.jdata['Links']
            for link in Links:
                temp_name = os.path.join(seg_dir, link['panoId'] + '.png')
                if temp_name in seg_files:
                    try:
                        seg_files.remove(temp_name)
                        seg_files.append(temp_name)
                    except:
                        pass

            if is_processed:
                print("Skip: ", seg_file)
                continue
            pano1 = GSV_pano(panoId=panoId,
                             crs_local=6487,
                             saved_path=saved_path)
            # pano1 = GSV_pano(request_lon = lon, request_lat=lat, saved_path=r'J:\Research\StreetView\gsv_pano\test_results')
            pano1.set_segmentation_path(full_path=seg_file)
            DOM = pano1.get_DOM(width=40,
                                height=40,
                                resolution=resolution,
                                zoom=4,
                                img_type='segmentation',
                                fill_clipped_seg=True)
            total_time = (time.perf_counter() - start_time_all)

            efficency = total_time / (total_cnt - len(seg_files))
            time_remain = efficency * len(seg_files)
            print(
                f"Time spent (seconds): {time.perf_counter() - start_time:.1f}, time used: {delta_time(total_time)} , time remain: {delta_time(time_remain)}  \n"
            )
            # palette = Image.open(seg_file).getpalette()
            # palette = np.array(palette,dtype=np.uint8)

            # pil_img = PIL.Image.fromarray(DOM['DOM'])
            # pil_img.putpalette(palette)
            # self.assertEqual((800, 800, 3), DOM.shape)
            # pil_img.show()
        except Exception as e:
            print("Error :", e, seg_file)
            continue