Пример #1
0
def list_to_img(all_left_img,
                all_right_img,
                all_left_disp,
                index,
                batchsize,
                training=True,
                use_bn=False):
    list_left_img = []
    list_right_img = []
    list_left_disp = []
    initial_index = index * batchsize
    for i in range(batchsize):
        left_img = Image.open(all_left_img[initial_index + i]).convert('RGB')
        right_img = Image.open(all_right_img[initial_index + i]).convert('RGB')
        left_disp, _ = rp.readPFM(all_left_disp[initial_index + i])
        left_disp = np.ascontiguousarray(left_disp, dtype=np.float32)
        if training:
            w, h = left_img.size
            th, tw = 256, 512
            x1 = random.randint(0, w - tw)
            y1 = random.randint(0, h - th)
            left_img = left_img.crop((x1, y1, x1 + tw, y1 + th))
            right_img = right_img.crop((x1, y1, x1 + tw, y1 + th))
            left_disp = left_disp[y1:y1 + th, x1:x1 + tw]
        left_img = np.array(left_img, dtype=np.float32)
        right_img = np.array(right_img, dtype=np.float32)
        if use_bn:
            left_img = scale_crop(left_img)
            right_img = scale_crop(right_img)
        list_left_img.append(left_img)
        list_right_img.append(right_img)
        list_left_disp.append(left_disp)
    batch_left_img = np.array(list_left_img)
    batch_right_img = np.array(list_right_img)
    batch_left_disp = np.array(list_left_disp)
    return batch_left_img, batch_right_img, batch_left_disp
Пример #2
0
def disparity_loader(path):
    return rp.readPFM(path)
Пример #3
0
def disparity_loader(path):
    # print(path)
    img = rp.readPFM(path)
    plt.imshow(img)
    plt.show()
    return img
Пример #4
0
def disparity_loader(path):
    # print(path)
    return rp.readPFM(path)
Пример #5
0
def disparity_loader(path):
    return rp.readPFM(path, False)  #Don't flip pfm