out-of-the-box


Nameout-of-the-box JSON
Version 1.3.0 PyPI version JSON
download
home_pageNone
Summary"I like to get into boxes."
upload_time2024-09-20 21:18:27
maintainerNone
docs_urlNone
authorPypayaTech
requires_python<4.0,>=3.8
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Out of the Box

"I like to get into boxes."

A comprehensive toolkit for handling bounding boxes in various formats, including a GUI for ROI selection. For those who like to think out of the box.

![Out of the box](out_of_the_box.png)

## Features

- Bounding box utilities:
  - Support for VOC, COCO, and YOLO formats
  - Conversion between formats
  - Area calculation
  - Intersection over Union (IoU) calculation
  - Drawing bounding boxes on images

- Roy app:
  - Load any image file supported by PIL
  - Draw and adjust bounding box interactively
  - Display coordinates in both pixel and normalized formats
  - Real-time updates of bounding box parameters

## Installation

```
pip install out-of-the-box
```

## Usage

### Bounding box utilities

```python
img_shape = (500, 500)
img = np.zeros((*img_shape, 3), dtype=np.uint8)

# Create bounding boxes in different formats
voc_box = VOCBox(100, 100, 300, 300)
coco_box = COCOBox(100, 100, 200, 200)
yolo_box = YOLOBox(0.4, 0.4, 0.2, 0.2)

bb_voc = BoundingBox(voc_box, img_shape)
bb_coco = BoundingBox(coco_box, img_shape)
bb_yolo = BoundingBox(yolo_box, img_shape)

# Print bounding boxes
print("VOC bounding box:", bb_voc)
print("COCO bounding box:", bb_coco)
print("YOLO bounding box:", bb_yolo)

# Convert between formats
print("\nFormat conversions:")
print("VOC to COCO:", bb_voc.to_coco())
print("COCO to YOLO:", bb_coco.to_yolo())
print("YOLO to VOC:", bb_yolo.to_voc())

# Normalized and pixel coordinates
print("\nNormalized and pixel coordinates:")
print("VOC (normalized):", bb_voc.to_voc(normalized=True))
print("COCO (pixel):", bb_yolo.to_coco(normalized=False))

# Area calculation
print("\nAreas:")
print("VOC box area:", bb_voc.area)
print("COCO box area:", bb_coco.area)
print("YOLO box area:", bb_yolo.area)

# Intersection and Union
intersection = BoundingBox.intersection(bb_voc, bb_coco)
union = BoundingBox.union(bb_voc, bb_coco)
print("\nIntersection and Union:")
print(f"Intersection between VOC and COCO: {intersection:.2f}")
print(f"Union between VOC and COCO: {union:.2f}")

# IoU calculation
iou = BoundingBox.iou(bb_voc, bb_coco)
print(f"IoU between VOC and COCO boxes: {iou:.2f}")

# Percentage inside
percentage = bb_coco.percentage_inside(bb_voc)
print(f"\nPercentage of COCO box inside VOC box: {percentage:.2%}")

# Center point
print("\nCenter points:")
print("VOC box center:", bb_voc.center)
print("COCO box center:", bb_coco.center)
print("YOLO box center:", bb_yolo.center)

# Contains point
test_point = (200, 200)
print(f"\nPoint {test_point} contained in:")
print("VOC box:", bb_voc.contains_point(test_point))
print("COCO box:", bb_coco.contains_point(test_point))
print("YOLO box:", bb_yolo.contains_point(test_point))

# Overlap percentage
overlap = bb_coco.overlap_percentage(bb_voc)
print(f"\nOverlap percentage of COCO box with VOC box: {overlap:.2%}")

# Draw the bounding boxes on the image
img = bb_voc.draw_on_image(img, color=COLOR_RED, thickness=2, label="VOC")
img = bb_coco.draw_on_image(img, color=COLOR_GREEN, thickness=2, label="COCO")
img = bb_yolo.draw_on_image(img, color=COLOR_BLUE, thickness=2, label="YOLO")

# Display the image
cv2.imshow("Image with bounding boxes", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
```

### Roy App

![Example of selecting ROI in the app](example.png)

To start the ROI selector GUI:

```bash
roy
```

In the GUI:

1. Click "Open Image" to load an image.
2. Draw a bounding box by clicking and dragging on the image.
3. Adjust the box using the entry fields or by dragging.
4. View both pixel and normalized coordinates.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "out-of-the-box",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "PypayaTech",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/0a/f4/91cd2ad55b780905b845c47b5e81ee6b179dd1885a5f71f0720acf8cfdec/out_of_the_box-1.3.0.tar.gz",
    "platform": null,
    "description": "# Out of the Box\n\n\"I like to get into boxes.\"\n\nA comprehensive toolkit for handling bounding boxes in various formats, including a GUI for ROI selection. For those who like to think out of the box.\n\n![Out of the box](out_of_the_box.png)\n\n## Features\n\n- Bounding box utilities:\n  - Support for VOC, COCO, and YOLO formats\n  - Conversion between formats\n  - Area calculation\n  - Intersection over Union (IoU) calculation\n  - Drawing bounding boxes on images\n\n- Roy app:\n  - Load any image file supported by PIL\n  - Draw and adjust bounding box interactively\n  - Display coordinates in both pixel and normalized formats\n  - Real-time updates of bounding box parameters\n\n## Installation\n\n```\npip install out-of-the-box\n```\n\n## Usage\n\n### Bounding box utilities\n\n```python\nimg_shape = (500, 500)\nimg = np.zeros((*img_shape, 3), dtype=np.uint8)\n\n# Create bounding boxes in different formats\nvoc_box = VOCBox(100, 100, 300, 300)\ncoco_box = COCOBox(100, 100, 200, 200)\nyolo_box = YOLOBox(0.4, 0.4, 0.2, 0.2)\n\nbb_voc = BoundingBox(voc_box, img_shape)\nbb_coco = BoundingBox(coco_box, img_shape)\nbb_yolo = BoundingBox(yolo_box, img_shape)\n\n# Print bounding boxes\nprint(\"VOC bounding box:\", bb_voc)\nprint(\"COCO bounding box:\", bb_coco)\nprint(\"YOLO bounding box:\", bb_yolo)\n\n# Convert between formats\nprint(\"\\nFormat conversions:\")\nprint(\"VOC to COCO:\", bb_voc.to_coco())\nprint(\"COCO to YOLO:\", bb_coco.to_yolo())\nprint(\"YOLO to VOC:\", bb_yolo.to_voc())\n\n# Normalized and pixel coordinates\nprint(\"\\nNormalized and pixel coordinates:\")\nprint(\"VOC (normalized):\", bb_voc.to_voc(normalized=True))\nprint(\"COCO (pixel):\", bb_yolo.to_coco(normalized=False))\n\n# Area calculation\nprint(\"\\nAreas:\")\nprint(\"VOC box area:\", bb_voc.area)\nprint(\"COCO box area:\", bb_coco.area)\nprint(\"YOLO box area:\", bb_yolo.area)\n\n# Intersection and Union\nintersection = BoundingBox.intersection(bb_voc, bb_coco)\nunion = BoundingBox.union(bb_voc, bb_coco)\nprint(\"\\nIntersection and Union:\")\nprint(f\"Intersection between VOC and COCO: {intersection:.2f}\")\nprint(f\"Union between VOC and COCO: {union:.2f}\")\n\n# IoU calculation\niou = BoundingBox.iou(bb_voc, bb_coco)\nprint(f\"IoU between VOC and COCO boxes: {iou:.2f}\")\n\n# Percentage inside\npercentage = bb_coco.percentage_inside(bb_voc)\nprint(f\"\\nPercentage of COCO box inside VOC box: {percentage:.2%}\")\n\n# Center point\nprint(\"\\nCenter points:\")\nprint(\"VOC box center:\", bb_voc.center)\nprint(\"COCO box center:\", bb_coco.center)\nprint(\"YOLO box center:\", bb_yolo.center)\n\n# Contains point\ntest_point = (200, 200)\nprint(f\"\\nPoint {test_point} contained in:\")\nprint(\"VOC box:\", bb_voc.contains_point(test_point))\nprint(\"COCO box:\", bb_coco.contains_point(test_point))\nprint(\"YOLO box:\", bb_yolo.contains_point(test_point))\n\n# Overlap percentage\noverlap = bb_coco.overlap_percentage(bb_voc)\nprint(f\"\\nOverlap percentage of COCO box with VOC box: {overlap:.2%}\")\n\n# Draw the bounding boxes on the image\nimg = bb_voc.draw_on_image(img, color=COLOR_RED, thickness=2, label=\"VOC\")\nimg = bb_coco.draw_on_image(img, color=COLOR_GREEN, thickness=2, label=\"COCO\")\nimg = bb_yolo.draw_on_image(img, color=COLOR_BLUE, thickness=2, label=\"YOLO\")\n\n# Display the image\ncv2.imshow(\"Image with bounding boxes\", img)\ncv2.waitKey(0)\ncv2.destroyAllWindows()\n```\n\n### Roy App\n\n![Example of selecting ROI in the app](example.png)\n\nTo start the ROI selector GUI:\n\n```bash\nroy\n```\n\nIn the GUI:\n\n1. Click \"Open Image\" to load an image.\n2. Draw a bounding box by clicking and dragging on the image.\n3. Adjust the box using the entry fields or by dragging.\n4. View both pixel and normalized coordinates.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "\"I like to get into boxes.\"",
    "version": "1.3.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ae9ab2715f7838be898decd8c6c45838fe5a1eeb593d261b97719a7464c5ed55",
                "md5": "48f91ea1c4c1c4c8d50705c2b91d095e",
                "sha256": "428ab5e8bba0394dadc43afca61b8cd9a59e7dc61ed597329de322e019f20e38"
            },
            "downloads": -1,
            "filename": "out_of_the_box-1.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "48f91ea1c4c1c4c8d50705c2b91d095e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 12304,
            "upload_time": "2024-09-20T21:18:26",
            "upload_time_iso_8601": "2024-09-20T21:18:26.062841Z",
            "url": "https://files.pythonhosted.org/packages/ae/9a/b2715f7838be898decd8c6c45838fe5a1eeb593d261b97719a7464c5ed55/out_of_the_box-1.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0af491cd2ad55b780905b845c47b5e81ee6b179dd1885a5f71f0720acf8cfdec",
                "md5": "d3829e6eafd71be69a39e3c90840d9cb",
                "sha256": "7512d3e3b731b3710073a81600a398ff84d82587af9cb36517efaf7d8baa86fc"
            },
            "downloads": -1,
            "filename": "out_of_the_box-1.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d3829e6eafd71be69a39e3c90840d9cb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 10716,
            "upload_time": "2024-09-20T21:18:27",
            "upload_time_iso_8601": "2024-09-20T21:18:27.714153Z",
            "url": "https://files.pythonhosted.org/packages/0a/f4/91cd2ad55b780905b845c47b5e81ee6b179dd1885a5f71f0720acf8cfdec/out_of_the_box-1.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-20 21:18:27",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "out-of-the-box"
}
        
Elapsed time: 0.71808s