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.0.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.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: boxjoin-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 77198b7d29bd9943357e175dd259225d0813df9b0efed2a2ac26b40613557b12
MD5 15335cf49c155a308e5ccf26bfb39a0e
BLAKE2b-256 d8e31e5ce69e4b3490eb00f3dd56714d43f8842005b36d3135a734128f73043a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: boxjoin-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86da80ac430032d2e3ec303a7b14a8cf75f3664f9d7b40227537cc28fc0e18ea
MD5 ca6363c0136bb85371412bd6044d2e98
BLAKE2b-256 b18e2567d2c2d61a1979dd5f1231f44107d34109decb57268c581b7d2187b4af

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