bbox-visualizer2


Namebbox-visualizer2 JSON
Version 0.0.4 PyPI version JSON
download
home_page
SummaryA bounding box visualizer
upload_time2023-07-16 11:49:56
maintainer
docs_urlNone
author
requires_python>=3.7
licenseMIT License Copyright (c) 2023 Fansure Grin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords bbox object-detection visualizer
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # BBox-Visualizer2

This is a python package for visualizing bounding boxes and adding labels to a given image. The creation of this package is inspired by [shoumikchow/bbox-visualizer](https://github.com/shoumikchow/bbox-visualizer), but I re-implement it through `Pillow` instead of `cv2`.

The format of a bounding box is `(xmin, ymin, xmax, ymax)`.

## Installation
### From `Pypi`
```
pip install bbox-visualizer2
```

### From source
```
git clone https://github.com/fansuregrin/bbox-visualizer2.git bbv2
cd bbv2
python3 -m pip install --upgrade build
python3 -m build
pip install dist/bbox_visualizer2-0.0.2-py3-none-any.whl
```

## Usage
You can see [demos](./demos/) for details.

### Multiple bboxes visualization
<details><summary>Code examples</summary>
<p>

```python
classes = [
    'person', 'bird',
    'cat', 'cow',
    'dog', 'horse',
    'sheep', 'aeroplane',
    'bicycle', 'boat',
    'bus', 'car',
    'motorbike', 'train',
    'bottle', 'chair',
    'diningtable', 'pottedplant',
    'sofa', 'tvmonitor',
]
font_path = 'assets/fonts/LXGWWenKai-Regular.ttf'
img_path = 'assets/images/000623.jpg'
pil_img = Image.open(img_path)
img = np.asarray(pil_img, dtype=np.uint8)
xml_filepath = 'assets/annotations/000623.xml'
boxes, labels = get_annot_info(xml_filepath, classes)

bbox_visualizer = bbv.BBoxVisualizer(classes, font_path)
img = bbox_visualizer.visualize_bbox(img, boxes, labels)
```

</p>
</details>

![](assets/images/000623_result.png)

![](assets/images/000127_result.png)

![](assets/images/000014_result.png)

### Single bbox visualization

#### (1) Label on the top of the bbox
<details><summary>Code examples</summary>
<p>

```python
label = 'cow'
box = [299, 160, 446, 252]
color = (255, 255, 0)
text_color = (0, 0, 0)

img1 = bbv.draw_rectangle(img, box, bbox_color=color, thickness=1)
img1 = bbv.add_label(img1, label, box, size=12, draw_bg=True,
                     text_bg_color=color, alpha=0.5, text_color=text_color,
                     top=True, font_fp=font_path)
```

</p>
</details>

![](assets/images/000013_result1.png)

#### (2) Label inside the box
<details><summary>Code examples</summary>
<p>

```python
label = 'cow'
box = [299, 160, 446, 252]
color = (255, 255, 0)
text_color = (0, 0, 0)

img2 = bbv.draw_rectangle(img, box, bbox_color=color, thickness=3)
img2 = bbv.add_label(img2, label, box, size=12, draw_bg=True,
                     text_bg_color=color, alpha=0.5, text_color=text_color,
                     top=False, font_fp=font_path)
```

</p>
</details>

![](assets/images/000013_result2.png)

#### (3) Set the box to opaque
<details><summary>Code examples</summary>
<p>

```python
label = 'cow'
box = [299, 160, 446, 252]
color = (255, 255, 0)
text_color = (0, 0, 0)

img3 = bbv.draw_rectangle(img, box, bbox_color=color, is_opaque=True, alpha=0.5)
img3 = bbv.add_label(img3, label, box, size=12, draw_bg=True,
                     text_bg_color=color, alpha=0.5, text_color=text_color,
                     top=False, font_fp=font_path)
```

</p>
</details>

![](assets/images/000013_result3.png)
            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "bbox-visualizer2",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "bbox,object-detection,visualizer",
    "author": "",
    "author_email": "Fansure Grin <pwz113436@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/6a/b1/c25d887263c3458523a852bfcb3592e9a2708571247d92e39b61c96e3425/bbox_visualizer2-0.0.4.tar.gz",
    "platform": null,
    "description": "# BBox-Visualizer2\n\nThis is a python package for visualizing bounding boxes and adding labels to a given image. The creation of this package is inspired by [shoumikchow/bbox-visualizer](https://github.com/shoumikchow/bbox-visualizer), but I re-implement it through `Pillow` instead of `cv2`.\n\nThe format of a bounding box is `(xmin, ymin, xmax, ymax)`.\n\n## Installation\n### From `Pypi`\n```\npip install bbox-visualizer2\n```\n\n### From source\n```\ngit clone https://github.com/fansuregrin/bbox-visualizer2.git bbv2\ncd bbv2\npython3 -m pip install --upgrade build\npython3 -m build\npip install dist/bbox_visualizer2-0.0.2-py3-none-any.whl\n```\n\n## Usage\nYou can see [demos](./demos/) for details.\n\n### Multiple bboxes visualization\n<details><summary>Code examples</summary>\n<p>\n\n```python\nclasses = [\n    'person', 'bird',\n    'cat', 'cow',\n    'dog', 'horse',\n    'sheep', 'aeroplane',\n    'bicycle', 'boat',\n    'bus', 'car',\n    'motorbike', 'train',\n    'bottle', 'chair',\n    'diningtable', 'pottedplant',\n    'sofa', 'tvmonitor',\n]\nfont_path = 'assets/fonts/LXGWWenKai-Regular.ttf'\nimg_path = 'assets/images/000623.jpg'\npil_img = Image.open(img_path)\nimg = np.asarray(pil_img, dtype=np.uint8)\nxml_filepath = 'assets/annotations/000623.xml'\nboxes, labels = get_annot_info(xml_filepath, classes)\n\nbbox_visualizer = bbv.BBoxVisualizer(classes, font_path)\nimg = bbox_visualizer.visualize_bbox(img, boxes, labels)\n```\n\n</p>\n</details>\n\n![](assets/images/000623_result.png)\n\n![](assets/images/000127_result.png)\n\n![](assets/images/000014_result.png)\n\n### Single bbox visualization\n\n#### (1) Label on the top of the bbox\n<details><summary>Code examples</summary>\n<p>\n\n```python\nlabel = 'cow'\nbox = [299, 160, 446, 252]\ncolor = (255, 255, 0)\ntext_color = (0, 0, 0)\n\nimg1 = bbv.draw_rectangle(img, box, bbox_color=color, thickness=1)\nimg1 = bbv.add_label(img1, label, box, size=12, draw_bg=True,\n                     text_bg_color=color, alpha=0.5, text_color=text_color,\n                     top=True, font_fp=font_path)\n```\n\n</p>\n</details>\n\n![](assets/images/000013_result1.png)\n\n#### (2) Label inside the box\n<details><summary>Code examples</summary>\n<p>\n\n```python\nlabel = 'cow'\nbox = [299, 160, 446, 252]\ncolor = (255, 255, 0)\ntext_color = (0, 0, 0)\n\nimg2 = bbv.draw_rectangle(img, box, bbox_color=color, thickness=3)\nimg2 = bbv.add_label(img2, label, box, size=12, draw_bg=True,\n                     text_bg_color=color, alpha=0.5, text_color=text_color,\n                     top=False, font_fp=font_path)\n```\n\n</p>\n</details>\n\n![](assets/images/000013_result2.png)\n\n#### (3) Set the box to opaque\n<details><summary>Code examples</summary>\n<p>\n\n```python\nlabel = 'cow'\nbox = [299, 160, 446, 252]\ncolor = (255, 255, 0)\ntext_color = (0, 0, 0)\n\nimg3 = bbv.draw_rectangle(img, box, bbox_color=color, is_opaque=True, alpha=0.5)\nimg3 = bbv.add_label(img3, label, box, size=12, draw_bg=True,\n                     text_bg_color=color, alpha=0.5, text_color=text_color,\n                     top=False, font_fp=font_path)\n```\n\n</p>\n</details>\n\n![](assets/images/000013_result3.png)",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Fansure Grin  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "A bounding box visualizer",
    "version": "0.0.4",
    "project_urls": {
        "Bug Tracker": "https://github.com/fansuregrin/bbox-visualizer2/issues",
        "Homepage": "https://github.com/fansuregrin/bbox-visualizer2"
    },
    "split_keywords": [
        "bbox",
        "object-detection",
        "visualizer"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "911b777ceafe97841450dd045fd128ac31b6d696f16b4571284452a53ca1cf8b",
                "md5": "8c76989defbe3fc628ece3c078b6470c",
                "sha256": "dc33cd4240ba84bf12b71dafd9168445fd6632b7a6d5f8efd1f6a6c5cb937ea8"
            },
            "downloads": -1,
            "filename": "bbox_visualizer2-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8c76989defbe3fc628ece3c078b6470c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 6606,
            "upload_time": "2023-07-16T11:49:52",
            "upload_time_iso_8601": "2023-07-16T11:49:52.118827Z",
            "url": "https://files.pythonhosted.org/packages/91/1b/777ceafe97841450dd045fd128ac31b6d696f16b4571284452a53ca1cf8b/bbox_visualizer2-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6ab1c25d887263c3458523a852bfcb3592e9a2708571247d92e39b61c96e3425",
                "md5": "34f17fb89ee0aa1564a23f043cd640ad",
                "sha256": "a2b6568b68f8a4557ef16579a44efcfd58dc35649962ce0cfff0305616c5e28b"
            },
            "downloads": -1,
            "filename": "bbox_visualizer2-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "34f17fb89ee0aa1564a23f043cd640ad",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 12813197,
            "upload_time": "2023-07-16T11:49:56",
            "upload_time_iso_8601": "2023-07-16T11:49:56.919375Z",
            "url": "https://files.pythonhosted.org/packages/6a/b1/c25d887263c3458523a852bfcb3592e9a2708571247d92e39b61c96e3425/bbox_visualizer2-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-16 11:49:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "fansuregrin",
    "github_project": "bbox-visualizer2",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "bbox-visualizer2"
}
        
Elapsed time: 0.20788s