Esempio n. 1
0
def plot(pts, colors, dir, label_mean, label):

    ext = label[5:8]
    theta = label[8:10]
    center = np.array([0., 0., 0.])

    box_min = label_mean - (ext / 2)
    box_max = label_mean + (ext / 2)
    box = np.hstack((box_min, box_max))

    box_pts = helpers.rotate_box(box, label_mean, theta)

    plot = pv.Plotter()

    plot.add_points(label_mean,
                    color=[0, 1, 0],
                    render_points_as_spheres=True,
                    point_size=30)
    plot.add_points(pts,
                    scalars=colors,
                    rgb=True,
                    render_points_as_spheres=True,
                    point_size=20)
    plot.add_arrows(center, dir, 0.75, color=[0, 0, 1])

    for l in helpers.make_lines(box_pts):
        plot.add_mesh(l, color=[1, 0, 0], line_width=6)

    plot.show()
Esempio n. 2
0
def plot_kitti(scan, img, pred_c, pred_attr, pred_clf, label):

    cmap = helpers.colormap(cfg['model']['n_classes'])

    pred_oabb = helpers.kitti_scenenet_to_oabb(pred_c, pred_attr)

    label_mask = tf.cast(label['bbox_3d'], tf.bool)[:, :, 0, 0]
    label_oabb = tf.boolean_mask(label['bbox_3d'], label_mask).numpy()

    plot = pv.Plotter(off_screen=not VIS,
                      shape=(2, 1),
                      window_size=(1240, 800))

    plot.subplot(0, 0)
    plot.add_points(scan, scalars=scan[:, 2], render_points_as_spheres=True)

    for i, box in enumerate(pred_oabb):
        for l in helpers.make_lines(box):
            plot.add_mesh(l, color=cmap[pred_clf[i][0]], line_width=3)

    for i, box in enumerate(label_oabb):
        for l in helpers.make_lines(box):
            plot.add_mesh(l, color=[0, 1, 0], line_width=3)

    plot.view_xz()

    plot.subplot(1, 0)
    img = np.flip(img.transpose(1, 0, 2), 1)
    cpos = [(img.shape[0] / 2., img.shape[1] / 2., 770),
            (img.shape[0] / 2., img.shape[1] / 2., 0.0), (0.0, 1.0, 0.0)]
    plot.camera_position = cpos
    plot.add_mesh(img[:, :, None, 0],
                  scalars=img.reshape((-1, 3), order='F'),
                  rgb=True)
    plot.remove_scalar_bar()

    if VIS:
        plot.show()
    else:
        if not os.path.isdir(SCREENSHOT_SAVE_DIR):
            os.makedirs(SCREENSHOT_SAVE_DIR)
        plot.show(screenshot=os.path.join(SCREENSHOT_SAVE_DIR,
                                          'pred_{}'.format(int(time.time()))))
def plot_scene(scene, scene_pts, scene_ext, gt_pts, gt_ext):

    pts = scene[:, 0:3]
    cols = scene[:, 3:6]

    cols = cols[pts[:, 2] < np.max(pts[:, 2]) - 1.5]
    pts = pts[pts[:, 2] < np.max(pts[:, 2]) - 1.5]

    plot = pv.Plotter()
    plot.set_background('white')

    plot.add_points(pts,
                    scalars=cols,
                    rgb=True,
                    opacity=1,
                    render_points_as_spheres=True,
                    point_size=10)

    if scene_pts.shape[0] > 0:

        ext_hwd = scene_ext[:, :3]
        ext_theta = scene_ext[:, 3:5]

        boxes_min = scene_pts - (ext_hwd / 2)
        boxes_max = scene_pts + (ext_hwd / 2)
        boxes = np.hstack((boxes_min, boxes_max))

        box_pts = helpers.rotate_boxes(boxes, scene_pts, ext_theta)

        classes = np.linspace(0, 1, box_pts.shape[0] + 1)
        rgb_classes = np.array(
            [colorsys.hsv_to_rgb(c, 0.8, 0.8) for c in classes])

        for i, box in enumerate(box_pts):
            lines = helpers.make_lines(box)
            [
                plot.add_mesh(l, color=rgb_classes[i], line_width=4)
                for l in lines
            ]

    plot.view_xy()
    plot.show()
Esempio n. 4
0
def plot(pts, colors, labels):

    labels_mask = labels.astype(np.bool)[:, 0]
    labels = labels[labels_mask]

    centers = labels[:, :3]
    ext = labels[:, 3:6]
    theta = labels[:, 6:8]

    boxes_min = centers - (ext / 2)
    boxes_max = centers + (ext / 2)
    boxes = np.hstack((boxes_min, boxes_max))

    obj_pts = rotate_boxes(boxes, centers, theta)

    plot = pv.Plotter()
    plot.view_xy()

    # Remove ceiling
    colors = colors[pts[:, 2] < np.max(pts[:, 2]) - 1.]
    pts = pts[pts[:, 2] < np.max(pts[:, 2]) - 1.]

    plot.add_points(pts,
                    scalars=colors,
                    rgb=True,
                    render_points_as_spheres=True,
                    point_size=15)
    plot.add_points(labels[:, :3],
                    color=[0, 0, 1],
                    render_points_as_spheres=True,
                    point_size=20)

    classes = np.linspace(0, 1, obj_pts.shape[0] + 1)
    rgb_classes = np.array([colorsys.hsv_to_rgb(c, 0.8, 0.8) for c in classes])

    for i, pts in enumerate(obj_pts):
        lines = helpers.make_lines(pts)
        for l in lines:
            plot.add_mesh(l, color=rgb_classes[i], line_width=6)

    plot.show()