3 Can only be used by integrations that have pillow in their requirements.
6 from __future__
import annotations
8 from PIL.ImageDraw
import ImageDraw
13 box: tuple[float, float, float, float],
17 color: tuple[int, int, int] = (255, 255, 0),
19 """Draw a bounding box on and image.
21 The bounding box is defined by the tuple (y_min, x_min, y_max, x_max)
22 where the coordinates are floats in the range [0.0, 1.0] and
23 relative to the width and height of the image.
25 For example, if an image is 100 x 200 pixels (height x width) and the bounding
26 box is `(0.1, 0.2, 0.5, 0.9)`, the upper-left and bottom-right coordinates of
27 the bounding box will be `(40, 10)` to `(180, 50)` (in (x,y) coordinates).
32 y_min, x_min, y_max, x_max = box
33 (left, right, top, bottom) = (
40 [(left, top), (left, bottom), (right, bottom), (right, top), (left, top)],
46 (left + line_width, abs(top - line_width - font_height)),
49 font_size=font_height,
None draw_box(ImageDraw draw, tuple[float, float, float, float] box, int img_width, int img_height, str text="", tuple[int, int, int] color=(255, 255, 0))