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.3.0.tar.gz (4.9 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.3.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for boxjoin-0.3.0.tar.gz
Algorithm Hash digest
SHA256 1c1907fb63c4f7d66b61854268adc1c98cf5ddaeb71ce99da291e686035b044b
MD5 9dca8749eb095ccb8ace201233912cee
BLAKE2b-256 9fd0bde69068e702e8efb2e82686e7dbb665d240846a4a77f4b69f2eb7a40e90

See more details on using hashes here.

File details

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

File metadata

  • Download URL: boxjoin-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d20476123f005c29e205337d7355589d7dad65f7ccf42df716de16f9fe686c9
MD5 c9601f32e0d102881633cd928ff97ebd
BLAKE2b-256 f1f55faae9df5293fa0a3ba8951d669acf78f89f4fc31eb9e1a898526a4ae805

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