Skip to contents

Draws bounding boxes (and optional labels) from a COCO-style annotation file on top of an image. Returns a magick-image object that can be printed or written to disk.

Usage

pg_plot_annotations(
  image_path,
  annotation_json,
  categories = NULL,
  class_colors = NULL,
  outline_width = 4,
  label = TRUE,
  label_cex = 0.8,
  label_alpha = 0.6,
  label_colour = "white"
)

Arguments

image_path

Path to the image file.

annotation_json

Path to the COCO annotations JSON containing the image.

categories

Optional vector of category names or ids to keep. NULL keeps all.

class_colors

Optional named vector of colours keyed by category name.

outline_width

Line width for bounding boxes.

label

Whether to draw category labels.

label_cex

Text expansion factor for labels.

label_alpha

Alpha for label background fill.

label_colour

Label text colour.

Value

A magick-image with annotations drawn.