Exemple #1
0
def filter_seq3(seq_list: FrameSeqData, base_dir):

    for seq in seq_list.frames:

        pre_frame = seq[0]
        center_frame = seq[1]
        next_frame = seq[2]

        pre_Tcw = seq_list.get_Tcw(pre_frame)
        center_Tcw = seq_list.get_Tcw(center_frame)
        next_Tcw = seq_list.get_Tcw(next_frame)

        K_mat = seq_list.get_K_mat(center_frame)

        # Read Image
        pre_img_name = seq_list.get_image_name(pre_frame)
        center_img_name = seq_list.get_image_name(center_frame)
        next_img_name = seq_list.get_image_name(pre_frame)
        pre_img = cv2.imread(os.path.join(base_dir, pre_img_name)).astype(
            np.float32) / 255.0
        center_img = cv2.imread(os.path.join(
            base_dir, center_img_name)).astype(np.float32) / 255.0
        next_img = cv2.imread(os.path.join(base_dir, next_img_name)).astype(
            np.float32) / 255.0

        # Read depth
        pre_depth_name = seq_list.get_depth_name(pre_frame)
        center_depth_name = seq_list.get_depth_name(center_frame)
        next_depth_name = seq_list.get_depth_name(next_frame)
        pre_depth = read_sun3d_depth(pre_depth_name)
        center_depth = read_sun3d_depth(center_depth_name)
        next_depth = read_sun3d_depth(next_depth_name)
Exemple #2
0
from core_io.depth_io import load_depth_from_png

valid_set_dir = '/home/ziqianb/Desktop/datasets/tgz_target/'
valid_seq_name = 'rgbd_dataset_freiburg1_desk'

seq = FrameSeqData(os.path.join(valid_set_dir, valid_seq_name, 'seq.json'))

frame_a = seq.frames[5]
frame_b = seq.frames[20]

Tcw_a = seq.get_Tcw(frame_a)
Tcw_b = seq.get_Tcw(frame_b)
K = seq.get_K_mat(frame_a)

img_a = cv2.imread(os.path.join(
    valid_set_dir, seq.get_image_name(frame_a))).astype(np.float32) / 255.0
img_b = cv2.imread(os.path.join(
    valid_set_dir, seq.get_image_name(frame_b))).astype(np.float32) / 255.0
depth_a = load_depth_from_png(os.path.join(valid_set_dir,
                                           seq.get_depth_name(frame_a)),
                              div_factor=5000.0)
depth_b = load_depth_from_png(os.path.join(valid_set_dir,
                                           seq.get_depth_name(frame_b)),
                              div_factor=5000.0)

rel_T = cam_opt.relateive_pose(Tcw_a[:3, :3], Tcw_a[:3, 3], Tcw_b[:3, :3],
                               Tcw_b[:3, 3])
wrap_b2a, _ = cam_opt.wrapping(img_a, img_b, depth_a, K, rel_T[:3, :3],
                               rel_T[:3, 3])
dense_a2b, _ = cam_opt.dense_corres_a2b(depth_a, K, Tcw_a, Tcw_b)
overlap_marks = cam_opt.mark_out_bound_pixels(dense_a2b, depth_a)
Exemple #3
0
        for seq_name in list_f:
            seq_name = seq_name.strip()
            seq_name_list.append(seq_name)

    for seq_name in tqdm(seq_name_list[-1:],
                         desc='generating lmdbs for sequences'):
        seq_file_path = os.path.join(dataset_dir, seq_name, 'seq.json')
        if not os.path.exists(seq_file_path):
            continue
        seq = FrameSeqData(seq_file_path)

        seq_lmdb = LMDBSeqModel(
            os.path.join(dataset_dir, seq_name, 'rgbd.lmdb'))
        for frame_idx in range(0, 80, 20):
            frame = seq.frames[frame_idx]
            img_path = os.path.join(dataset_dir, seq.get_image_name(frame))
            img2 = cv2.imread(img_path)
            depth_path = os.path.join(dataset_dir, seq.get_depth_name(frame))
            depth = read_sun3d_depth(depth_path)
            depth = cv2.resize(depth, (320, 240),
                               interpolation=cv2.INTER_NEAREST)

            img_key = seq.get_image_name(frame)
            depth_key = seq.get_depth_name(frame)

            img = seq_lmdb.read_img(img_key)
            depth2 = seq_lmdb.read_depth(depth_key)

            plt.imshow(depth, cmap='jet')
            plt.show()
            plt.imshow(depth2, cmap='jet')