vis4d.vis.image.canvas.pillow_backend
Pillow backend implementation to draw on images.
Classes
|
Canvas backend using Pillow. |
- class PillowCanvasBackend(font=None, font_size=None)[source]
Canvas backend using Pillow.
- __init__(font=None, font_size=None)[source]
Creates a new canvas backend.
- Parameters:
font (ImageFont) – Pillow font to use for the label.
font_size (int) – Font size to use for the label.
- create_canvas(image=None, image_hw=None)[source]
Creates a new canvas with a given image or shape internally.
Either provide a background image or the desired height, width of the canvas.
- Parameters:
image (np.array[uint8] | None) – Numpy array with a background image
image_hw (tuple[int, int] | None) – height, width of the canvas
- Raises:
ValueError – If the canvas is not initialized.
- Return type:
None
- draw_bitmap(bitmap, color, top_left_corner=(0, 0), alpha=0.5)[source]
Draws a binary mask onto the given canvas.
- Parameters:
bitmap (ndarray) – The binary mask to draw.
color (tuple[int, int, int]) – Color of the box [0,255].
top_left_corner (tuple(float, float)) – Coordinates of top left corner of the bitmap.
alpha (float) – Alpha value for transparency of this mask.
- Raises:
ValueError – If the canvas is not initialized.
- Return type:
None
- draw_text(position, text, color=(255, 255, 255))[source]
Draw text onto canvas at given position.
- Parameters:
position (tuple[float, float]) – x,y position where the text will start.
text (str) – Text to be placed at the given location.
color (tuple[int, int, int], optional) – Text color. Defaults to (255, 255, 255).
- Raises:
ValueError – If the canvas is not initialized.
- Return type:
None
- draw_box(corners, color, width=1)[source]
Draws a box onto the given canvas.
- Parameters:
corners (list[float]) – Containing [x1,y2,x2,y2] the corners of the box.
color (tuple[int, int, int]) – Color of the box [0,255].
width (int, optional) – Line width. Defaults to 1.
- Raises:
ValueError – If the canvas is not initialized.
- Return type:
None
- draw_rotated_box(corners, color, width=0)[source]
Draws a box onto the given canvas.
Corner ordering:
+———+ (3) | | | | | |
+———+ (1)
- Parameters:
corners (list[tuple[float, float]]) – Containing the four corners of the box.
color (tuple[int, int, int]) – Color of the box [0,255].
width (int, optional) – Line width. Defaults to 0.
- Raises:
ValueError – If the canvas is not initialized.
- Return type:
None
- draw_line(point1, point2, color, width=0)[source]
Draw a line onto canvas from point 1 to 2.
- Parameters:
point1 (tuple[float, float]) – Start point (2D pixel coordinates).
point2 (tuple[float, float]) – End point (2D pixel coordinates).
color (tuple[int, int, int]) – Color of the line.
width (int, optional) – Line width. Defaults to 0.
- Raises:
ValueError – If the canvas is not initialized.
- Return type:
None
- draw_circle(center, color, radius=2)[source]
Draw a circle onto canvas.
- Parameters:
center (tuple[float, float]) – Center of the circle.
color (tuple[int, int, int]) – Color of the circle.
radius (int, optional) – Radius of the circle. Defaults to 2.
- Return type:
None
- draw_box_3d(corners, color, intrinsics, width=0, camera_near_clip=0.15, plot_heading=True)[source]
Draws a 3D box onto the given canvas.
- Return type:
None