{"id":23288357,"url":"https://github.com/sebrovater/bbox_objected","last_synced_at":"2026-02-15T12:37:18.573Z","repository":{"id":181157514,"uuid":"532207309","full_name":"SEBROVATER/bbox_objected","owner":"SEBROVATER","description":"'bbox' in object form","archived":false,"fork":false,"pushed_at":"2025-02-06T18:05:46.000Z","size":158,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-09T12:22:54.564Z","etag":null,"topics":["bbox","cv","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SEBROVATER.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-03T08:57:38.000Z","updated_at":"2025-02-06T18:05:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"0fd4958d-fa06-4bc2-bcbc-ce3d50074565","html_url":"https://github.com/SEBROVATER/bbox_objected","commit_stats":null,"previous_names":["sebrovater/bbox_objected"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/SEBROVATER/bbox_objected","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SEBROVATER%2Fbbox_objected","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SEBROVATER%2Fbbox_objected/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SEBROVATER%2Fbbox_objected/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SEBROVATER%2Fbbox_objected/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SEBROVATER","download_url":"https://codeload.github.com/SEBROVATER/bbox_objected/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SEBROVATER%2Fbbox_objected/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260419657,"owners_count":23006328,"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":["bbox","cv","python"],"created_at":"2024-12-20T03:16:51.457Z","updated_at":"2026-02-15T12:37:13.554Z","avatar_url":"https://github.com/SEBROVATER.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bbox-objected\n\n---\n\nMakes manipulating bounding boxes easier in Computer Vision projects, \nwith zero dependencies by default.\n---\n\n## Installation:\n\n`pip install bbox-objected` - without any sub-dependencies\n\n### Optional dependencies:\n\nYou can install `numpy` or `opencv` separately. But just for fun, some extra options exist:\n\n`pip install bbox-objected[opencv]` - adds `opencv-python` as a subdependency.\n\n`pip install bbox-objected[headless]` - adds `opencv-python-headless` as a subdependency.\n\n`pip install bbox-objected[contrib]` - adds `opencv-contrib-python` as a subdependency.\n\n`pip install bbox-objected[contrib-headless]` - adds `opencv-contrib-python-headless` as a subdependency.\n\n`numpy` is included with each of the options above.\n\n\u003e Be aware that different `opencv` versions are incompatible with each other.\n\n## Examples:\n`AbsBBox` is needed to store absolute coordinates (uses `int` type strictly)\n\n```python\nfrom bbox_objected import AbsBBox\n\nbbox = AbsBBox((35, 45, 100, 80), kind=\"x1y1wh\", text=\"abs_sample\")\n\nassert repr(bbox) == \"\u003cAbsBBox(x1=35, y1=45, x2=135, y2=125) - abs_sample\u003e\"\nassert bbox.get_x1y1x2y2() == (35, 45, 135, 125)\n```\nIf you need to store relative coordinates, you can use `RelBBox` (values in range [0., 1.])\n\n```python\nfrom bbox_objected import RelBBox\n\nbbox = RelBBox((0.1, 0.2, 0.5, 0.6), kind=\"x1x2y1y2\", text=\"rel_sample\")\n\nassert repr(bbox) == \"\u003cRelBBox(x1=0.1, y1=0.5, x2=0.2, y2=0.6) - rel_sample\u003e\"\nassert bbox.get_tl_tr_br_bl() == ((0.1, 0.5), (0.2, 0.5), (0.2, 0.6), (0.1, 0.6))\n```\nConversion between types is available\n\n```python\nfrom bbox_objected import RelBBox\n\nbbox = RelBBox((0.1, 0.2, 0.5, 0.6), kind=\"x1y1x2y2\", text=\"sample\")\n\nassert repr(bbox) == \"\u003cRelBBox(x1=0.1, y1=0.2, x2=0.5, y2=0.6) - sample\u003e\"\nassert (\n    repr(bbox.as_abs(1920, 1080))\n    == \"\u003cAbsBBox(x1=192, y1=216, x2=960, y2=648) - sample\u003e\"\n)\nassert (\n    bbox.as_abs(1920, 1080).as_rel(1920, 1080) is not bbox\n)\n```\nThere is a bunch of attributes for each bbox\n\n```python\nfrom bbox_objected import RelBBox, AbsBBox\n\nbbox = AbsBBox((40, 40, 60, 60))\n\nassert (bbox.x1, bbox.y1, bbox.x2, bbox.y2) == (40, 40, 60, 60)\nassert (bbox.w, bbox.h) == (20, 20)\nassert (bbox.tl, bbox.tr, bbox.br, bbox.bl) == ((40, 40), (60, 40), (60, 60), (40, 60))\n\nbbox = AbsBBox((40, 40, 60, 60))\n\nassert (bbox.center, bbox.area) == ((50.0, 50.0), 400)\nassert (bbox.xc, bbox.yc) == (50.0, 50.0)\n```\nAvailable _**kinds**_ of bboxes:\n\n```python\nfrom bbox_objected.annotations import BBoxKind\n\n# special format of 'EasyOCR' library\nassert BBoxKind.free_list == \"tl_tr_br_bl\"\nassert BBoxKind.tl_tr_br_bl == \"tl_tr_br_bl\"\n# special format of 'EasyOCR' library\nassert BBoxKind.horizontal_list == \"x1x2y1y2\"\nassert BBoxKind.x1x2y1y2 == \"x1x2y1y2\"\n# own format of PascalVOC image dataset\nassert BBoxKind.pascal_voc == \"x1y1x2y2\"\nassert BBoxKind.x1y1x2y2 == \"x1y1x2y2\"\n# own format of COCO image dataset\nassert BBoxKind.coco == \"x1y1wh\"\nassert BBoxKind.x1y1wh == \"x1y1wh\"\n# gets special coords format of 'WinOCR' library\nassert BBoxKind.winocr == \"winocr\"\n# gets 'monitor' object of library 'mss'\nassert BBoxKind.mss == \"mss\"\n```\nThere is respective `get_` method for each bbox _**kind**_, except `\"winocr\"`\n\nSome simple editing of bboxes is also available\n\n```python\nfrom bbox_objected import AbsBBox\n\nbbox = AbsBBox((100, 200, 300, 400))\nassert repr(bbox) == \"\u003cAbsBBox(x1=100, y1=200, x2=300, y2=400)\u003e\"\n\nbbox.zero_basis()\nassert repr(bbox) == \"\u003cAbsBBox(x1=0, y1=0, x2=200, y2=200)\u003e\"\n\nbbox.move_basis(25, 45)\nassert repr(bbox) == \"\u003cAbsBBox(x1=25, y1=45, x2=225, y2=245)\u003e\"\n\nother_bbox = AbsBBox((200, 300, 400, 500))\nassert repr(other_bbox) == \"\u003cAbsBBox(x1=200, y1=300, x2=400, y2=500)\u003e\"\n\n# chooses coords to get max area, doesn't create new instance\nbbox.update_from(other_bbox)\nassert repr(bbox) == \"\u003cAbsBBox(x1=25, y1=45, x2=400, y2=500)\u003e\"\n\n# takes all coords from 'other', doesn't create new instance\nbbox.replace_from(other_bbox)\nassert repr(bbox) == \"\u003cAbsBBox(x1=200, y1=300, x2=400, y2=500)\u003e\"\n```\n\n\n## Additional functionality:\nEach bbox can be drawn or cropped from image. Can work both with `AbsBBox` and `RelBBox`\n\n```python\nimport numpy as np\nimport cv2\n\nfrom bbox_objected import AbsBBox\n\nbbox = AbsBBox((100, 200, 300, 400))  # 'x1y1x2y2' bbox kind is default\n\nimg = np.empty((512, 512, 3), dtype=np.uint8)  # random RGB image\n\ncropped = bbox.crop_from(img)  # 'numpy' must be installed\nassert cropped.shape == (200, 200, 3)\n\nbbox.show_on(img, text=\"sample\")  # 'opencv' must be installed\ncv2.waitKey(1)\ncv2.destroyAllWindows()\n```\nAlso, there are several useful functions. Currently, works only with `AbsBBox`.\n\n```python\nfrom bbox_objected import AbsBBox\nfrom bbox_objected.bbox_utils import get_distance, get_IoU, get_cos_between\n\nbbox_1 = AbsBBox((100, 200, 300, 400), kind=\"x1y1wh\")\nbbox_2 = AbsBBox((100, 400, 100, 400), kind=\"horizontal_list\")\n\nassert get_distance(bbox_1, bbox_2) == 150.0\n# Intersection over Union\nassert get_IoU(bbox_1, bbox_2) == 0.4\n# angle around center in (450 ,350)\nassert get_cos_between(bbox_1, bbox_2, 450, 350) == 0.7592566023652966\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebrovater%2Fbbox_objected","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebrovater%2Fbbox_objected","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebrovater%2Fbbox_objected/lists"}