Skip to main content

Bounding box clustering: group overlapped box into a large box

Project description

boxjoin

Install

pip install boxjoin

How it works

It works by detecting overlapped bounding box. Overlapped box will be grouped as one large bouding box. It is useful for grouping some bounding box (from YOLO, etc). But, currently it is not label aware and working based on coordinate.

Showcase

Inference Grouped

Inference Grouped

Example

import boxjoin
import cv2

filename = "people-walking-original.jpg"
save_path = "people-walking-original-grouped.jpg"

img = cv2.imread(filename)

# Each box is in the format of [x1, y1, x2, y2]
# They can be extracted from YOLO output.
# This example is simply for demonstration
boxes = [
    [143, 91, 174, 118],
    [142, 98, 164, 123],
    [143, 87, 204, 165],
    [127, 118, 225, 181],
    [371, 195, 386, 220],
    [334, 152, 380, 243],
    [293, 193, 335, 301],
    [470, 136, 494, 167],
    [464, 123, 500, 214],
    [565, 234, 586, 260],
    [554, 178, 582, 261],
    [219, 313, 261, 405],
    [182, 297, 223, 387],
    [151, 315, 196, 421]
]

clusters = boxjoin.BoxClustering(boxes=boxes, img=img, save_path=save_path)

for i, cluster in enumerate(clusters):
    print(f"Cluster {i}: {cluster}")
    # The output should look like this:
    # Cluster 0: [[143, 91, 174, 118], [142, 98, 164, 123], [143, 87, 204, 165], [127, 118, 225, 181]]
    # Cluster 1: [[371, 195, 386, 220], [334, 152, 380, 243], [293, 193, 335, 301]]
    # Cluster 2: [[470, 136, 494, 167], [464, 123, 500, 214]]
    # Cluster 3: [[565, 234, 586, 260], [554, 178, 582, 261]]
    # Cluster 4: [[219, 313, 261, 405], [182, 297, 223, 387], [151, 315, 196, 421]]

Full example can be found in example directory

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

boxjoin-0.2.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

boxjoin-0.2.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file boxjoin-0.2.1.tar.gz.

File metadata

  • Download URL: boxjoin-0.2.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for boxjoin-0.2.1.tar.gz
Algorithm Hash digest
SHA256 36652e0d89cfe327afcdce62739dad65aa371d86d406e5b857d7be40010d257c
MD5 5a4c545b96d8215534c9fec0ad35a1f0
BLAKE2b-256 316304accbe045ed2319b5589267430ca021571f8ee7a10ad0b7206c1df85dc6

See more details on using hashes here.

File details

Details for the file boxjoin-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: boxjoin-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for boxjoin-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ba3a90193832b80ad98a393f618fe903d5656ee6a13591e0aa7e4bcf46f442b2
MD5 aba2a99264c72de7964d9a850ee6f1f8
BLAKE2b-256 017fbfc98c6f2a8ef4f70bb36dd5e2860b6f42f601f2be4040cb4aca0826d6d8

See more details on using hashes here.

Supported by

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