imgutils.detect.visual

Overview:

Visualize the detection results.

See imgutils.detect.head.detect_heads() and imgutils.detect.person.detect_person() for examples.

detection_visualize

imgutils.detect.visual.detection_visualize(image: str | PathLike | bytes | bytearray | BinaryIO | Image, detection: List[Tuple[Tuple[float, float, float, float], str, float]], labels: List[str] | None = None, text_padding: int = 6, fontsize: int = 12, fp=None, no_label: bool = False)[source]
Overview:

Visualize the results of the object detection.

Parameters:
  • image – Image be detected.

  • detection – The detection results list, each item includes the detected area (x0, y0, x1, y1), the target type (always head) and the target confidence score.

  • labels – An array of known labels. If not provided, the labels will be automatically detected from the given detection.

  • text_padding – Text padding of the labels. Default is 6.

  • fontsize – Font size of the labels. At runtime, an attempt will be made to retrieve the font used for rendering from matplotlib. Therefore, if matplotlib is not installed, only the default pixel font provided with Pillow can be used, and the font size cannot be changed.

  • no_label – Do not show labels. Default is False.

Returns:

A PIL image with the same size as the provided image image, which contains the original image content as well as the visualized bounding boxes.

Examples::

See imgutils.detect.head.detect_heads() and imgutils.detect.person.detect_person() for examples.