Skip to main content

Package to simplify bounding boxes usage

Project description

bounding_box

A Python package designed to simplify bounding box operations for object detection. It provides functions to calculate box centers, dimensions, and intersections, reducing the complexity of these tasks in your code. With Bounding_Box, you can streamline your object detection workflow, making it more efficient and straightforward.

Example

from bounding_box import BoundingBox
import numpy as np
import cv2

img = np.zeros((750,1000,3))

bounding_box = BoundingBox([547.31, 41.473, 940.4, 712.92])
bounding_box_2 = BoundingBox((500, 20, 700, 350))

bounding_box_3 = bounding_box_2.change_size(0.4, False)

line = (100, 250, 530, 250)

img = cv2.line(img, line[:2], line[2:], (255,255,0), 2)

img = cv2.rectangle(img, bounding_box[:2], bounding_box[2:], (255,0,0), 2)

img = cv2.rectangle(img, bounding_box_2[:2], bounding_box_2[2:], (0,255,0), 2)

img = cv2.rectangle(img, bounding_box_3[:2], bounding_box_3[2:], (0,0,255), 2)

print("Bounding box 2 is intercepting blue line: ", bounding_box_2.box_intercept_line(line))
print("bounding box is intercepting bounding_box_2: ", bounding_box.box_intercept_box(bounding_box_2.bounding_box))
print("How much of bounding_box_2 is in bounding_box: ", bounding_box_2.iou(bounding_box.bounding_box))
print("Bounding box 3 values: ", bounding_box_3.bounding_box)
print("Bounding box 3 listed values: ", bounding_box_3.list_bounding_box)
print("Bounding box 3 middle: ", bounding_box_3.middle)
print("Bounding box 3 listed middle: ", bounding_box_3.list_middle)
print("Bounding box 3 dimensions: ", bounding_box_3.dimensions)
print("Bounding box 3 listed dimensions: ", bounding_box_3.list_dimensions)
print("Bounding box 3 area: ", bounding_box_3.area)
print("Bounding box 3 walls coordinates: ", bounding_box_3.walls)

cv2.imshow("image", img)
  
cv2.waitKey(0)

cv2.destroyAllWindows()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easy_bounding_box-0.0.3.tar.gz (5.6 kB view hashes)

Uploaded Source

Built Distribution

easy_bounding_box-0.0.3-py3-none-any.whl (7.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page