{"id":21970199,"url":"https://github.com/pandede/bbox","last_synced_at":"2025-03-22T22:42:37.993Z","repository":{"id":166904414,"uuid":"642369071","full_name":"Pandede/bbox","owner":"Pandede","description":"a Python library handles 2D Bounding box","archived":false,"fork":false,"pushed_at":"2023-08-21T02:36:19.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-06T17:06:14.906Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Pandede.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-05-18T12:16:04.000Z","updated_at":"2024-07-14T12:44:59.000Z","dependencies_parsed_at":"2023-09-24T05:11:40.070Z","dependency_job_id":null,"html_url":"https://github.com/Pandede/bbox","commit_stats":{"total_commits":26,"total_committers":1,"mean_commits":26.0,"dds":0.0,"last_synced_commit":"3f3986f9793d7a4d9a5a5b6ccf33cd1ccc37881d"},"previous_names":["pandede/bbox"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pandede%2Fbbox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pandede%2Fbbox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pandede%2Fbbox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pandede%2Fbbox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pandede","download_url":"https://codeload.github.com/Pandede/bbox/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245031351,"owners_count":20549913,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-29T14:37:56.319Z","updated_at":"2025-03-22T22:42:37.960Z","avatar_url":"https://github.com/Pandede.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bbox\n\nDealing with the bounding box is pretty common and important in the related tasks of object detection or tracking, such as `Yolo` and `Deepsort`. Handling with `bbox` can greatly reduce the development time and reduce the chance of errors on bounding box.\n\n## Installation\nInstalling `bbox` and the dependencies via `pip`\n```bash\npip install git+https://github.com/Pandede/bbox\n```\n\n## Quick start\n\n\n### Basic operations\n```python\nfrom bbox import BoundingBox\n\n# Create a bounding box in format `xywh`\nbbox = BoundingBox(x=0, y=0, w=10, h=10)\n\n# ... or in format `xyxy`\nbbox = BoundingBox.from_xyxy(0, 0, 10, 10)\n\n# ... or in format `tlwh`\nbbox = BoundingBox.from_tlwh(0, 0, 10, 10)\n\n# Get the width and height\nprint(bbox.width, bbox.height)  # 10 10\n\n# ... or in short form\nw, h = bbox.w, bbox.h   # 10 10\n\n# Get the area\nprint(bbox.area)    # 100\n\n# Check if the bounding boxes are identical\nbbox_a = BoundingBox(x=0, y=0, w=10, h=10)\nbbox_b = BoundingBox.from_xyxy(-5, -5, 5, 5)\nprint(bbox_a == bbox_a) # True\n```\n\n### Anchor\n```python\nfrom bbox import BoundingBox\n\n# Get the coordinate of edge point by calling `anchor(index)`\n# The returned point refers to the position of number on NumPad:\n# 7---8---9\n# |       |\n# 4   5   6\n# |       |\n# 1---2---3\n\nbbox = BoundingBox.from_xyxy(0, 0, 10, 10)\n\n# Get the coordinate of bottom-left point\nprint(bbox.anchor(1))   # (0, 10)\n\n# Get the coordinate of center point\nprint(bbox.anchor(5))   # (5, 5)\n```\n\n### Format\n```python\nfrom bbox import BoundingBox\n\n# The `BoundingBox` object stores the attributes `xywh`\nbbox = BoundingBox(x=5, y=5, w=10, h=10)\nprint((bbox.x, bbox.y, bbox.w, bbox.h))   # (5, 5, 10, 10)\n\n# Format it to `xyxy`\nprint(bbox.to_xyxy())   # (0, 0, 10, 10)\n\n# Format it to `tlwh`\nprint(bbox.to_tlwh())   # (0, 0, 10, 10)\n```\n\n## Measurement\n### Area\n```python\nfrom bbox import BoundingBox\nfrom bbox.measure import union, intersect\n\nbbox_a = BoundingBox.from_xyxy(0, 0, 10, 10)\nbbox_b = BoundingBox.from_xyxy(5, 5, 15, 15)\n\n# Get the union area of bounding boxes\nprint(union(bbox_a, bbox_b))    # 175\n\n# Get the intersection area of bounding boxes\nprint(intersect(bbox_a, bbox_b))    # 25\n```\n\n### IoU (Intersection over Union)\n```python\nfrom bbox import BoundingBox\nfrom bbox.measure import iou, giou, diou, ciou\n\nbbox_a = BoundingBox.from_xyxy(0, 0, 10, 10)\nbbox_b = BoundingBox.from_xyxy(5, 5, 15, 15)\n\n# Compute the IoU and its variation\nprint(f'IoU: {iou(bbox_a, bbox_b):.6f}')    # IoU: 0.142857\nprint(f'GIoU: {giou(bbox_a, bbox_b):.6f}')  # GIoU: -0.079365\nprint(f'DIoU: {diou(bbox_a, bbox_b):.6f}')  # DIoU: 0.0153061\nprint(f'CIoU: {ciou(bbox_a, bbox_b):.6f}')  # CIoU: 0.0153061\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpandede%2Fbbox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpandede%2Fbbox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpandede%2Fbbox/lists"}