Reformat Markdown code blocks (#12795)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
parent
2af71d15a6
commit
fceea033ad
128 changed files with 1067 additions and 1018 deletions
|
|
@ -195,15 +195,15 @@ from ultralytics.data.utils import polygon2mask
|
|||
|
||||
imgsz = (1080, 810)
|
||||
polygon = np.array(
|
||||
[805, 392, 797, 400, ..., 808, 714, 808, 392], # (238, 2)
|
||||
[805, 392, 797, 400, ..., 808, 714, 808, 392], # (238, 2)
|
||||
)
|
||||
|
||||
mask = polygon2mask(
|
||||
imgsz, # tuple
|
||||
[polygon], # input as list
|
||||
color=255, # 8-bit binary
|
||||
downsample_ratio=1
|
||||
)
|
||||
imgsz, # tuple
|
||||
[polygon], # input as list
|
||||
color=255, # 8-bit binary
|
||||
downsample_ratio=1,
|
||||
)
|
||||
```
|
||||
|
||||
## Bounding Boxes
|
||||
|
|
@ -326,13 +326,15 @@ xywh
|
|||
### All Bounding Box Conversions
|
||||
|
||||
```python
|
||||
from ultralytics.utils.ops import xywh2xyxy
|
||||
from ultralytics.utils.ops import xywhn2xyxy # normalized → pixel
|
||||
from ultralytics.utils.ops import xyxy2xywhn # pixel → normalized
|
||||
from ultralytics.utils.ops import xywh2ltwh # xywh → top-left corner, w, h
|
||||
from ultralytics.utils.ops import xyxy2ltwh # xyxy → top-left corner, w, h
|
||||
from ultralytics.utils.ops import ltwh2xywh
|
||||
from ultralytics.utils.ops import ltwh2xyxy
|
||||
from ultralytics.utils.ops import (
|
||||
ltwh2xywh,
|
||||
ltwh2xyxy,
|
||||
xywh2ltwh, # xywh → top-left corner, w, h
|
||||
xywh2xyxy,
|
||||
xywhn2xyxy, # normalized → pixel
|
||||
xyxy2ltwh, # xyxy → top-left corner, w, h
|
||||
xyxy2xywhn, # pixel → normalized
|
||||
)
|
||||
```
|
||||
|
||||
See docstring for each function or visit the `ultralytics.utils.ops` [reference page](../reference/utils/ops.md) to read more about each function.
|
||||
|
|
@ -394,17 +396,18 @@ from ultralytics.utils.plotting import Annotator, colors
|
|||
obb_names = {10: "small vehicle"}
|
||||
obb_image = cv.imread("datasets/dota8/images/train/P1142__1024__0___824.jpg")
|
||||
obb_boxes = np.array(
|
||||
[[ 0, 635, 560, 919, 719, 1087, 420, 803, 261,], # class-idx x1 y1 x2 y2 x3 y2 x4 y4
|
||||
[ 0, 331, 19, 493, 260, 776, 70, 613, -171,],
|
||||
[ 9, 869, 161, 886, 147, 851, 101, 833, 115,]
|
||||
[
|
||||
[0, 635, 560, 919, 719, 1087, 420, 803, 261], # class-idx x1 y1 x2 y2 x3 y2 x4 y4
|
||||
[0, 331, 19, 493, 260, 776, 70, 613, -171],
|
||||
[9, 869, 161, 886, 147, 851, 101, 833, 115],
|
||||
]
|
||||
)
|
||||
ann = Annotator(
|
||||
obb_image,
|
||||
line_width=None, # default auto-size
|
||||
font_size=None, # default auto-size
|
||||
font="Arial.ttf", # must be ImageFont compatible
|
||||
pil=False, # use PIL, otherwise uses OpenCV
|
||||
font_size=None, # default auto-size
|
||||
font="Arial.ttf", # must be ImageFont compatible
|
||||
pil=False, # use PIL, otherwise uses OpenCV
|
||||
)
|
||||
for obb in obb_boxes:
|
||||
c_idx, *obb = obb
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue