def generate_ref(box, P):
    s1, s2, s3, s4 = (0.1, 0.2, 0.4, 0.8)

    z1 = np.arange(0, 70, s1) + s1 / 2.
    z2 = np.arange(0, 70, s2) + s2 / 2.
    z3 = np.arange(0, 70, s3) + s3 / 2.
    z4 = np.arange(0, 70, s4) + s4 / 2.

    cx, cy = (box[0] + box[2]) / 2., (box[1] + box[3]) / 2.,

    xyz1 = np.zeros((len(z1), 3))
    xyz1[:, 0] = cx
    xyz1[:, 1] = cy
    xyz1[:, 2] = z1
    xyz1_rect = project_image_to_rect(xyz1, P)

    xyz2 = np.zeros((len(z2), 3))
    xyz2[:, 0] = cx
    xyz2[:, 1] = cy
    xyz2[:, 2] = z2
    xyz2_rect = project_image_to_rect(xyz2, P)

    xyz3 = np.zeros((len(z3), 3))
    xyz3[:, 0] = cx
    xyz3[:, 1] = cy
    xyz3[:, 2] = z3
    xyz3_rect = project_image_to_rect(xyz3, P)

    xyz4 = np.zeros((len(z4), 3))
    xyz4[:, 0] = cx
    xyz4[:, 1] = cy
    xyz4[:, 2] = z4
    xyz4_rect = project_image_to_rect(xyz4, P)

    return xyz1_rect, xyz2_rect, xyz3_rect, xyz4_rect
Esempio n. 2
0
def check_box_frustum(box, P, center, dimension, angle):

    x1, y1, x2, y2 = box
    box_corner = compute_box_3d(center, dimension, angle, P)  # 8, 3

    z1 = np.arange(0, 70, 0.1)

    xyz1 = np.zeros((len(z1), 3))
    xyz1[:, 0] = x1
    xyz1[:, 1] = y1
    xyz1[:, 2] = z1
    xyz1_rect = project_image_to_rect(xyz1, P)

    xyz1[:, 0] = x2
    xyz1[:, 1] = y2
    xyz1[:, 2] = z1
    xyz2_rect = project_image_to_rect(xyz1, P)

    xyz1[:, 0] = x1
    xyz1[:, 1] = y2
    xyz1[:, 2] = z1
    xyz3_rect = project_image_to_rect(xyz1, P)

    xyz1[:, 0] = x2
    xyz1[:, 1] = y1
    xyz1[:, 2] = z1
    xyz4_rect = project_image_to_rect(xyz1, P)

    fig = plt.figure()
    ax = fig.gca(projection='3d')

    draw_box3d(box_corner, ax)
    draw_points(xyz1_rect, ax)
    draw_points(xyz2_rect, ax)
    draw_points(xyz3_rect, ax)
    draw_points(xyz4_rect, ax)

    plt.show()
    def generate_ref(self, box, P):

        s1, s2, s3, s4 = cfg.DATA.STRIDE
        max_depth = cfg.DATA.MAX_DEPTH

        z1 = np.arange(0, max_depth, s1) + s1 / 2.
        z2 = np.arange(0, max_depth, s2) + s2 / 2.
        z3 = np.arange(0, max_depth, s3) + s3 / 2.
        z4 = np.arange(0, max_depth, s4) + s4 / 2.

        cx, cy = (box[0] + box[2]) / 2., (box[1] + box[3]) / 2.,

        xyz1 = np.zeros((len(z1), 3))
        xyz1[:, 0] = cx
        xyz1[:, 1] = cy
        xyz1[:, 2] = z1
        xyz1_rect = project_image_to_rect(xyz1, P)

        xyz2 = np.zeros((len(z2), 3))
        xyz2[:, 0] = cx
        xyz2[:, 1] = cy
        xyz2[:, 2] = z2
        xyz2_rect = project_image_to_rect(xyz2, P)

        xyz3 = np.zeros((len(z3), 3))
        xyz3[:, 0] = cx
        xyz3[:, 1] = cy
        xyz3[:, 2] = z3
        xyz3_rect = project_image_to_rect(xyz3, P)

        xyz4 = np.zeros((len(z4), 3))
        xyz4[:, 0] = cx
        xyz4[:, 1] = cy
        xyz4[:, 2] = z4
        xyz4_rect = project_image_to_rect(xyz4, P)

        return xyz1_rect, xyz2_rect, xyz3_rect, xyz4_rect