util

util / BoundingBoxOnImage / 0.2.0

README.md

INTRODUCTION

This is an image processing algorithm that draws bounding boxes on any given image. It's a useful utility algorithm that is used across other algorithms that do object detection.

It also comes with a few predefined style sets (only 1 for now) you can automatically use, or provide your own custom settings.

Inputs:

  • (Required): Image source URL
  • (Required): Image save location
  • (Required): Bounding box(es) + optionally text objects
  • (Optional): Predefined style set name or custom style settings

Output:

  • Image with bounding box(es) drawn on it.

Predefined Style Sets: basic (default).

Examples

Example 1.

  • Parameter 1: Sample Image
  • Parameter 2: Output Image Save Location
  • Parameter 3: Bounding box information

Input Image:

Output Image:

Sample Input:

{
  "imageUrl": "data://util/BoundingBoxOnImage/three_people.jpg",
  "imageSaveUrl": "data://.algo/util/BoundingBoxOnImage/temp/output_1.png",
  "boundingBoxes": [
    {
      "coordinates": {
        "left": 1678,
        "right": 1900,
        "top": 1084,
        "bottom": 1307
      }
    },{
      "coordinates": {
        "left": 2306,
        "right": 2491,
        "top": 1089,
        "bottom": 1274
      }
    },{
      "coordinates": {
        "left": 3015,
        "right": 3238,
        "top": 910,
        "bottom": 1133
      }
    }
  ]
}

Example 2.

  • Parameter 1: Sample Image
  • Parameter 2: Output Image Save Location
  • Parameter 3: Bounding box information with text objects

Input Image:

Output Image:

Sample Input:

{
  "imageUrl": "data://util/BoundingBoxOnImage/three_people.jpg",
  "imageSaveUrl": "data://.algo/util/BoundingBoxOnImage/temp/output_2.png",
  "boundingBoxes": [
    {
      "coordinates": {
        "left": 1678,
        "right": 1900,
        "top": 1084,
        "bottom": 1307
      },
      "textObjects": [
        {
          "text": "Emily",
          "position": "bottom"
        }
      ]
    },{
      "coordinates": {
        "left": 2306,
        "right": 2491,
        "top": 1089,
        "bottom": 1274
      },
      "textObjects": [
        {
          "text": "Jay",
          "position": "top"
        }
      ]
    },{
      "coordinates": {
        "left": 3015,
        "right": 3238,
        "top": 910,
        "bottom": 1133
      },
      "textObjects": [
        {
          "text": "Jack",
          "position": "bottom"
        }
      ]
    }
  ]
}

Example 3.

  • Parameter 1: Sample Image
  • Parameter 2: Output Image Save Location
  • Parameter 3: Bounding box information with text objects
  • Parameter 3: A predefined style set

Input Image:

Output Image:

Sample Input:

{
  "imageUrl": "data://util/BoundingBoxOnImage/three_people.jpg",
  "imageSaveUrl": "data://.algo/util/BoundingBoxOnImage/temp/output_3.png",
  "boundingBoxes": [
    {
      "coordinates": {
        "left": 1678,
        "right": 1900,
        "top": 1084,
        "bottom": 1307
      },
      "textObjects": [
        {
          "text": "Emily",
          "position": "bottom"
        }
      ]
    },{
      "coordinates": {
        "left": 2306,
        "right": 2491,
        "top": 1089,
        "bottom": 1274
      },
      "textObjects": [
        {
          "text": "Jay",
          "position": "top"
        }
      ]
    },{
      "coordinates": {
        "left": 3015,
        "right": 3238,
        "top": 910,
        "bottom": 1133
      },
      "textObjects": [
        {
          "text": "Jack",
          "position": "bottom"
        }
      ]
    }
  ],
  "style": "basic"
}

Example 4.

  • Parameter 1: Sample Image
  • Parameter 2: Output Image Save Location
  • Parameter 3: Bounding box information with text objects
  • Parameter 3: Custom style settings

Input Image:

Output Image:

Sample Input:

{
  "imageUrl": "data://util/BoundingBoxOnImage/three_people.jpg",
  "imageSaveUrl": "data://.algo/util/BoundingBoxOnImage/temp/output_4.png",
  "boundingBoxes": [
    {
      "coordinates": {
        "left": 1678,
        "right": 1900,
        "top": 1084,
        "bottom": 1307
      },
      "textObjects": [
        {
          "text": "Emily",
          "position": "bottom"
        }
      ]
    },{
      "coordinates": {
        "left": 2306,
        "right": 2491,
        "top": 1089,
        "bottom": 1274
      },
      "textObjects": [
        {
          "text": "Jay",
          "position": "top"
        }
      ]
    },{
      "coordinates": {
        "left": 3015,
        "right": 3238,
        "top": 910,
        "bottom": 1133
      },
      "textObjects": [
        {
          "text": "Jack",
          "position": "bottom"
        }
      ]
    }
  ],
  "style": {
    "rect_thickness": 1,
    "rect_outer_thickness": 1,
    "rect_inner_thickness": 1,
    "top_font_size": 9,
    "bottom_font_size": 9,
    "top_font_offset": 2,
    "bottom_font_offset": 2,
    "top_font_background_outline_thickness": 1,
    "bottom_font_background_outline_thickness": 1,
    "bb_color": [255, 255, 255],
    "bb_outer_color": [255, 0, 0],
    "bb_inner_color": [255, 0, 0],
    "top_font_background_color": [255, 255, 255],
    "bottom_font_background_color": [255, 255, 255],
    "top_font_background_outline_color": [255, 0, 0],
    "bottom_font_background_outline_color": [255, 0, 0],
    "top_font_color": [255, 0, 0],
    "bottom_font_color": [255, 0, 0]
  }
}

Credits

Sample image from Unsplash.