Modules

class bbox.BoundingBox(x, y, w, h, c)

Bases: object

Bounding box around an object in an image

contains(x, y)

Tests if this bounding box contains a given (x,y) point

Returns:

True if this bounding box contains a point

Return type:

bool

get_area()
Returns:

area of the bounding box

Return type:

float

get_bottom_right()
Returns:

bottom right corner of the bounding box

Return type:

tuple (float, float)

get_center()
Returns:

center of the bounding box

Return type:

tuple (float, float)

get_confidence()
Returns:

confidence of the bounding box

Return type:

float

get_height()
Returns:

height of the bounding box

Return type:

float

get_top_left()
Returns:

top left corner of the bounding box

Return type:

tuple (float, float)

get_width()
Returns:

width of the bounding box

Return type:

float

get_xmax()
Returns:

x coordinate of bottom right corner of the bounding box

Return type:

float

get_xmin()
Returns:

x coordinate of top left corner of the bounding box

Return type:

float

get_ymax()
Returns:

y coordinate of bottom right corner of the bounding box

Return type:

float

get_ymin()
Returns:

y coordinate of top left corner of the bounding box

Return type:

float

int_area(other: BoundingBox)

Performs the intersection of this bounding box and another bounding box and returns the area of the intersection

Returns:

the intersection of this bounding box and another bounding box

Return type:

float

intersects(other: BoundingBox)

Tests if this bounding box intersects another bounding box

Returns:

True if this bounding box intersects another bounding box

Return type:

bool

iou(other: BoundingBox)

Calculates the intersection over union of this bounding box and another bounding box

Returns:

intersection over union of this bounding box and another bounding box

Return type:

float

on_edge(x, y, delta)

Tests if a given (x,y) point is on the edge of this bounding box

Returns:

True if a given (x,y) point is on the edge of this bounding box

Return type:

bool

union_area(other: BoundingBox)

Performs the union of this bounding box and another bounding box and returns the area of the union

Returns:

the union of this bounding box and another bounding box

Return type:

float

class gridcell.GridCell(width, height, i, j)

Bases: object

A section of an input image that is responsible for detecting objects. and generating bounding boxes for them.

add_bbox(bbox)

Make this grid cell responsible for the given bounding box.

Parameters:

bbox – BoundingBox

Returns:

None

get_bbox_list()

Return the list of bounding boxes for this grid cell.

Returns:

list of BoundingBox

Return type:

list[BoundingBox]

class utils.Utils

Bases: object

static draw_bbox_on_image(image_buf, bbox_list)

Draws bounding boxes on an image buffer.

Parameters:
  • image_buf (numpy.ndarray) – image buffer as a numpy array

  • bbox_list (list[BoundingBox]) – list of bounding boxes

Returns:

modified image buffer as a numpy array

Return type:

numpy.ndarray

static draw_grid_on_image(image_buf, grid_cells)

Draws grid cells on an image buffer.

Parameters:
  • image_buf (numpy.ndarray) – image buffer as a numpy array

  • grid_cells (list[GridCell]) – list of grid cells

Returns:

modified image buffer as a numpy array

Return type:

numpy.ndarray

static generate_grid_cells(image_size, grid_size)

Generates grid cells for an image.

Parameters:
  • image_size (tuple (int, int)) – size of the image

  • grid_size (tuple (int, int)) – size of the grid

Returns:

list of grid cells

Return type:

list[GridCell]

static get_rgba_int(r, g, b, a)
static open_toml(path)

Returns a dict with the contents of the toml file

Returns:

a dict from a toml file

Return type:

dict

static save_image_buf(image_buf, path, size=(448, 448, 3))

saves an image buffer to a file

Parameters:
  • image_buf (numpy.ndarray) – image buffer as a numpy array

  • path (str) – path to save the image to

  • size (tuple, optional) – size of the image, defaults to (448, 448, 3)

Returns:

None

Return type:

None