imgviz.draw.text_in_rectangle

imgviz.draw.text_in_rectangle(src, loc, text, size, background, color=None, aabb1=None, aabb2=None, font_path=None, keep_size=False)[source]

Draw text in a rectangle.

Parameters:
  • src (numpy.ndarray) – Input image.

  • loc (str) – Location of text. It must be one of following: lt, rt, lb, rb, lt+, rt+, lb-, rb-.

  • text (str) – Text to draw.

  • size (int) – Text size in pixel.

  • background ((3,) array-like) – Background color in uint8.

  • color ((3,) array-like) – Text RGB color in uint8. If None, the color is determined by background color. (default: None)

  • aabb1 ((2,) array-like) – Coordinate of the rectangle (y_min, x_min), (y_max, x_max). Default is (0, 0), (height, width).

  • aabb2 ((2,) array-like) – Coordinate of the rectangle (y_min, x_min), (y_max, x_max). Default is (0, 0), (height, width).

  • keep_size (bool) – Force to keep original size (size change happens with loc=xx+, xx-).

Returns:

dst – Output image.

Return type:

numpy.ndarray