コード例 #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)
コード例 #2
0
    def test_get_point_cloud(self):
        panoId_2019 = "BM1Qt23drK3-yMWxYfOfVg"
        panoId_2019 = "AZK1jDGIZC1zmuooSZCzEg"  # Walker Ave to Franlin Elementary

        # lat, lon = 40.7093514, -74.2453146  # road bridge ramp tilt, z = 37 m

        # lat, lon = 40.780667, -73.9610365
        pano1 = GSV_pano(panoId=panoId_2019, crs_local=6526)
        #     pano1 = GSV_pano(request_lon=lon, request_lat=lat, crs_local=6526, saved_path=os.getcwd())
        dm = pano1.get_depthmap(zoom=0, saved_path=os.getcwd())
        # point_cloud = pano1.get_point_cloud(distance_threshole=200, zoom=0)['point_cloud']
        point_cloud = pano1.get_ground_points(color=True, zoom=4)
        # point_cloud = pano1.get_DOM_points()

        print(point_cloud.shape)

        P = point_cloud
        v = pptk.viewer(P[:, :3])
        v.set(point_size=0.001, show_axis=False, show_grid=False)
        # v.attributes(P[:, 4:7] / 255.0, P[:, 3], P[:, 8:11]/255.0, P[:, 7])
        # v.attributes(P[:, 3:6] / 255.0)  # for DOM points
        v.attributes(P[:, 4:7] / 255.0)
コード例 #3
0
def quick_DOM():

    seg_dir = r'D:\DC_segmented'
    pano_dir = r'E:\USC_OneDrive\OneDrive - University of South Carolina\Research\sidewalk_wheelchair\DC_panoramas'
    seg_files = glob.glob(os.path.join(seg_dir, "*.png"))
    pano_files = glob.glob(os.path.join(pano_dir, "*.jpg"))
    saved_path = r'F:\Research\sidewalk_wheelchair\DOMs'
    resolution = 0.05

    img_w = 40
    img_h = 40
    zoom = 4

    # pano_files.reverse()
    # pano_files = pano_files[:]

    for idx, pano_file in enumerate(pano_files[20000:]):

        try:

            print(f"Processing: {idx} / {len(pano_files)}, {pano_file}")
            panoId = os.path.basename(pano_file)[:-6]

            new_name = os.path.join(saved_path,
                                    f"{panoId}_DOM_{resolution:0.2f}.tif")
            if os.path.exists(new_name):
                print(f"Skip processed panoramas: {panoId}")
                continue

            img_zoom = int(pano_file[-5])

            if img_zoom == 4:
                print("Skipe: ", pano_file)
                continue

            # if img_zoom == 5:
            #     img_zoom5 = Image.open(pano_file)
            #     pano_file = pano_file.replace("_5.jpg", "_4.jpg")

            timer_start = time.perf_counter()

            distance_threshole = img_w * 1.5

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

            pano1.get_depthmap(zoom=zoom)

            pano1.depthmap['ground_mask'] = np.where(
                pano1.depthmap['depthMap'] < distance_threshole, 1, 0)
            mask_h, mask_w = pano1.depthmap['ground_mask'].shape
            pano1.depthmap['ground_mask'][int(mask_h / 4 * 3):, :] = 0

            P = pano1.get_ground_points(zoom=zoom, color=True, img_type="pano")

            # P = P[P[:, 3] < distance_threshole]
            P = P[P[:, 0] < img_w / 2]
            P = P[P[:, 0] > -img_w / 2]
            P = P[P[:, 1] < img_h / 2]
            P = P[P[:, 1] > -img_h / 2]

            timer_end = time.perf_counter()

            np_img, worldfile = pano1.points_to_DOM(P[:, 0],
                                                    P[:, 1],
                                                    P[:, 4:7],
                                                    resolution=resolution)

            pano1.save_image(np_img, new_name, worldfile)

            print("Time spent (second):", timer_end - timer_start)
        except Exception as e:
            print("Error in quick_DOM():", pano_file, e)