# Changing bounding boxes to polygons

**URL:** <https://community.ultralytics.com/t/changing-bounding-boxes-to-polygons/578>\
**Category:** Discussion\
**Tags:** question\
**Created:** [December 7, 2024, 10:58am UTC](https://community.ultralytics.com/t/changing-bounding-boxes-to-polygons/578 "2024-12-07T10:58:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tw0trickp0ny](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/tw0trickp0ny/32/462_2.png) [@tw0trickp0ny](https://community.ultralytics.com/u/tw0trickp0ny)\
**Post date:** [December 7, 2024, 10:58am UTC](https://community.ultralytics.com/t/changing-bounding-boxes-to-polygons/578/1 "2024-12-07T10:58:46Z")

</div>

Hi all,  
I’m working on a project which requires me to quickly infer the four corners of a 2d projection of a square surface. Its shape is important to me and I do not want to use an analytical solution after running a bounding-box generating model. I decided to adapt YOLOv5 for this purpose. For that purpose I will need to change the model itself, in order to output 8 numbers (two x,y pairs for each corner) instead of the x,y,w,h standard. I have some questions:

First things first, is this possible? By possible I mean, possible without an unreasonable amount of work to the point where it’d be faster to just write and train a model from scratch.  
Second of all, is there perhaps a model you know which is better suited for my task?  
Third of all, is there something to look out for when changing yolov5’s output shape, to not break the model.  
Thanks for reading this and I’d appreciate any input on this, as I am still very green at object detecting NNs.

---

<div class="post-metadata">

**Author:** ![pderrenger](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/pderrenger/32/73_2.png) [@pderrenger](https://community.ultralytics.com/u/pderrenger)\
**Post date:** [December 7, 2024, 1:26pm UTC](https://community.ultralytics.com/t/changing-bounding-boxes-to-polygons/578/2 "2024-12-07T13:26:22Z")

</div>

Hello there! 😊

It’s great to see the enthusiasm for adapting YOLO to your project! Let me address your questions step-by-step:

1. **Is this possible?**  
Yes, adapting YOLOv5 to output corner coordinates instead of the standard `x, y, w, h` bounding box format is technically possible. However, this will involve modifying the architecture of the model, including:

2. **Are there better-suited models for this task?**  
Instead of modifying YOLOv5, you might want to explore models explicitly designed for polygon or oriented bounding box (OBB) detection. For example:

3. **Things to look out for when changing YOLOv5’s output shape:**  
When modifying YOLOv5’s output:

### Suggestions for Moving Forward:

- If this is your first time working with object detection NNs, I recommend starting with a model that already supports OBBs like YOLO11 rather than modifying YOLOv5 heavily. YOLO11 makes it easier to detect rotated objects and work with non-standard bounding box formats.
- To try YOLO11 for OBB detection, you can follow the [YOLO11 training guide for OBB](https://www.ultralytics.com/blog/how-to-use-ultralytics-yolo11-for-obb-object-detection). You might find its existing functionalities sufficient to your needs without requiring major adjustments.

Let me know if you’d like specific examples or need further guidance on any step! 🚀

---

<div class="post-metadata">

**Author:** ![Toxite](https://sea1.discourse-cdn.com/flex001/user_avatar/community.ultralytics.com/toxite/32/123_2.png) [@Toxite](https://community.ultralytics.com/u/Toxite)\
**Post date:** [December 7, 2024, 3:27pm UTC](https://community.ultralytics.com/t/changing-bounding-boxes-to-polygons/578/3 "2024-12-07T15:27:23Z")

</div>

You could try OBB models with `ultralytics`.

> **[OBB](https://docs.ultralytics.com/tasks/obb/)**
>
> Discover how to detect objects with rotation for higher precision using YOLO11 OBB models. Learn, train, validate, and export OBB models effortlessly.

You can get the four corners from the result. `result.obb.xyxyxyxy`.
