コード例 #1
0
    # # preds_X_3d = get_eyes_nose_3D_landmarks(img1, depth1, K1, Twc1, preds1)
    # # vis.set_point_cloud(preds_X_3d, lm_colors, pt_size=10, clear=False)
    #
    # T = np.eye(4, dtype=np.float32)
    # T[:3, :3] = R1
    # T[:3, 3] = t1
    # Twc1 = np.dot(T, Twc1)
    #
    # X_3d, colors = get_pt_from_img(img1, depth1, K1, Twc1)
    # vis.set_point_cloud(X_3d, colors, pt_size=3, clear=False)
    #
    # lm_colors[:, 1] = 0
    # preds_X_3d = get_eyes_nose_3D_landmarks(img1, depth1, K1, Twc1, preds1)
    # vis.set_point_cloud(preds_X_3d, lm_colors, pt_size=10, clear=False)
    #
    # vis.show()

    img, depth, K, Twc, deform = load_deform('deform.npz')
    H, W = depth.shape
    vis = Visualizer(1280, 720)

    X_3d, colors = get_pt_from_img(img, depth, K, Twc)
    vis.set_point_cloud(X_3d, colors, pt_size=3)
    X_3d_ = X_3d + deform.reshape((-1, 3))
    vis.set_point_cloud(X_3d_,
                        np.ones((X_3d_.shape[0], 3)),
                        pt_size=3,
                        clear=False)

    vis.show()
コード例 #2
0
        max_idx_ = max_idx
    for o in obs_cams:
        if o not in invalid_cam_flag and o not in valid_cam2idx:
            valid_cam2idx[o] = n_valid_Cams
            valid_cams.append(o)
            n_valid_Cams += 1

# point clouds
pts = gt_bundle2.points
pts_pos = [pt.X for pt in pts]
pts_pos = np.asarray(pts_pos)
pts_center = np.mean(pts_pos, axis=0)
dist = np.linalg.norm(pts_pos - pts_center, axis=1)
dist_flag = dist < 5.0
# pts_color = [pt.color for pt in pts]
# pts_color = np.asarray(pts_color)

filtered_pts = []
for i, pt in enumerate(pts):
    if dist_flag[i] == False:
        continue
    filtered_pts.append(pt.X)
pts_pos = np.asarray(filtered_pts)

vis = Visualizer(1024, 1024)
vis.set_point_cloud(pts_pos, pt_size=2)
for cam in cameras:
    vis.add_frame_pose(cam[:3, :3], cam[:3, 3])
# ipv_draw_pose_3d()
vis.show()
# print('Done')
コード例 #3
0
base_dir = '/home/ziqianb/Desktop/intel'

seq_name = 'apartment'

frames = FrameSeqData(os.path.join(base_dir, seq_name, 'seq.json'))
refer_T = frames.get_Tcw(frames.frames[0])
convert_rel_vo(frames, refer_T)

in_intrinsic = np.asarray([525.0, 525.0, 320.0, 240.0], dtype=np.float32)
in_K = cam_opt.K_from_intrinsic(in_intrinsic)
''' Scripts ------------------------------------------------------------------------------------------------------------
'''
plot_frames_seq_2d(frames, show_view_direction=True)
plt.show()

vis = Visualizer()
frame_idx = 0
x_2d = cam_opt.x_2d_coords(int(in_intrinsic[3] * 2), int(in_intrinsic[2] * 2))
# x_2d = cam_opt.x_2d_coords(480, 640)


def keyPressEvent(obj, event):
    global frame_idx
    global refer_T
    key = obj.GetKeySym()
    if key == 'Right':
        # vis.clear_frame_poses()
        # if frame_idx > 30:
        #     return

        cur_frame = frames.frames[frame_idx]
コード例 #4
0
        plot_array_seq_2d(seq_T, plt_axes=ax, show_view_direction=True, legend='ori', color='b')

        # Plot displacement radius
        for frame_idx in range(1, noise_T.shape[0]):
            T = seq_T[frame_idx]
            C = cam_opt.camera_center_from_Tcw(T[:3, :3], T[:3, 3])
            circle = plt.Circle((C[0], C[2]), 3 * rand_std_radius, color=(1.0, 0.0, 0.0, 0.1))
            ax.add_patch(circle)

        ax.set_aspect('equal', adjustable='box')
        plt.show()
    else:
        from visualizer.visualizer_3d import Visualizer

        # Show 3D case
        vis = Visualizer()

        count = 0
        def keyPressEvent(obj, event):
            global seq_T
            global noise_T
            global count
            key = obj.GetKeySym()
            if key == 'Right':
                vis.clear_frame_poses()
                if count % 2 == 0:
                    for frame_idx in range(0, noise_T.shape[0]):
                        T = seq_T[frame_idx]
                        R, t = cam_opt.Rt(T)
                        vis.add_frame_pose(R, t, color=(1.0, 1.0, 1.0), camera_obj_scale=0.05)
                else: