def pretty_render_3d_box(
    box3d,
    image,
    # camera,
    K,
    *,
    class_id=None,
    class_names=None,
    score=None,
    line_thickness=3,
    color=None,
    render_label=True
):
    """Render the bounding box on the image. NOTE: CV2 renders in place.

    Parameters
    ----------
    box3d: GenericBoxes3D

    image: np.uint8 array
        Image (H, W, C) to render the bounding box onto. We assume the input image is in *RGB* format

    K: np.ndarray
        Camera used to render the bounding box.

    line_thickness: int, default: 1
        Thickness of bounding box lines.

    font_scale: float, default: 0.5
        Font scale used in text labels.

    draw_axes: bool, default: False
        Whether or not to draw axes at centroid of box.
        Note: Bounding box pose is oriented such that x-forward, y-left, z-up.
        This corresponds to L (length) along x, W (width) along y, and H
        (height) along z.

    draw_text: bool, default: False
        If True, renders class name on box.
    """
    if not isinstance(box3d, GenericBoxes3D):
        raise ValueError(f'`box3d` must be a type of `Genericboxes3D`: {type(box3d).__str__()}')
    if (not isinstance(image, np.ndarray) or image.dtype != np.uint8 or len(image.shape) != 3 or image.shape[2] != 3):
        raise ValueError('`image` must be a 3-channel uint8 numpy array')

    points2d = project_points3d(box3d.corners[0].cpu().numpy(), K)
    corners = points2d.T

    # Draw the sides (first)
    for i in range(4):
        cv2.line(
            image, (int(corners.T[i][0]), int(corners.T[i][1])), (int(corners.T[i + 4][0]), int(corners.T[i + 4][1])),
            color,
            thickness=line_thickness
        )
    # Draw front (in red) and back (blue) face.
    cv2.polylines(image, [corners.T[:4].astype(np.int32)], True, color, thickness=line_thickness)
    cv2.polylines(image, [corners.T[4:].astype(np.int32)], True, color, thickness=line_thickness)

    front_face_as_polygon = corners.T[:4].ravel().astype(int).tolist()
    fill_color_polygon(image, front_face_as_polygon, color, alpha=0.5)

    V = VisImage(img=image)

    if render_label:
        # Render text label. Mostly copied from Visualizer.overlay_instances()
        label = _create_text_labels([class_id], [score] if score is not None else None, class_names)[0]
        # bottom-right corner
        text_pos = tuple([points2d[:, 0].min(), points2d[:, 1].max()])
        horiz_align = "left"
        lighter_color = change_color_brightness(tuple([c / 255. for c in color]), brightness_factor=0.8)
        H, W = image.shape[:2]
        default_font_size = max(np.sqrt(H * W) // 90, 10)
        height_ratio = (points2d[:, 1].max() - points2d[:, 1].min()) / np.sqrt(H * W)
        font_size = (np.clip((height_ratio - 0.02) / 0.08 + 1, 1.2, 2) * 0.5 * default_font_size)

        draw_text(V.ax, label, text_pos, font_size=font_size, color=lighter_color, horizontal_alignment=horiz_align)

    image = V.get_image()
    return image
Render the bounding box on the image. NOTE: CV2 renders in place.

    Parameters
    ----------
    box3d: GenericBoxes3D

    image: np.uint8 array
        Image (H, W, C) to render the bounding box onto. We assume the input image is in *RGB* format

    K: np.ndarray
        Camera used to render the bounding box.

    line_thickness: int, default: 1
        Thickness of bounding box lines.

    font_scale: float, default: 0.5
        Font scale used in text labels.

    draw_axes: bool, default: False
        Whether or not to draw axes at centroid of box.
        Note: Bounding box pose is oriented such that x-forward, y-left, z-up.
        This corresponds to L (length) along x, W (width) along y, and H
        (height) along z.

    draw_text: bool, default: False
        If True, renders class name on box.
    
tridet/visualizers/box3d_visualizer.py