drawAnnotations method

void drawAnnotations({
  1. required Image image,
  2. required List<Vertex> vertices,
  3. required Color color,
  4. int thickness = 3,
  5. bool isNormalized = false,
})

Draw a box on the supplied img.Image represented by ByteData around the detected object using Vertex values.

Implementation

void drawAnnotations({
  required img.Image image,
  required List<Vertex> vertices,
  required img.Color color,
  int thickness = 3,
  bool isNormalized = false,
}) {
  final topLeft = vertices.first;

  final bottomRight = vertices[2];

  img.drawRect(
    image,
    x1: isNormalized ? (topLeft.x * image.width).toInt() : topLeft.x.toInt(),
    y1: isNormalized ? (topLeft.y * image.height).toInt() : topLeft.y.toInt(),
    x2: isNormalized
        ? (bottomRight.x * image.width).toInt()
        : bottomRight.x.toInt(),
    y2: isNormalized
        ? (bottomRight.y * image.height).toInt()
        : bottomRight.y.toInt(),
    color: Util.convertColorNameToImageColor(argResults!['line-color']),
    thickness: thickness,
  );
}