mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-19 23:33:33 +08:00
Add: [ALAS] Util function xywh2xyxy(), xyxy2xywh()
This commit is contained in:
@@ -497,6 +497,22 @@ def location2node(location):
|
|||||||
return col2name(x) + str(y)
|
return col2name(x) + str(y)
|
||||||
|
|
||||||
|
|
||||||
|
def xywh2xyxy(area):
|
||||||
|
"""
|
||||||
|
Convert (x, y, width, height) to (x1, y1, x2, y2)
|
||||||
|
"""
|
||||||
|
x, y, w, h = area
|
||||||
|
return x, y, x + w, y + h
|
||||||
|
|
||||||
|
|
||||||
|
def xyxy2xywh(area):
|
||||||
|
"""
|
||||||
|
Convert (x1, y1, x2, y2) to (x, y, width, height)
|
||||||
|
"""
|
||||||
|
x1, y1, x2, y2 = area
|
||||||
|
return min(x1, x2), min(y1, y2), abs(x2 - x1), abs(y2 - y1)
|
||||||
|
|
||||||
|
|
||||||
def load_image(file, area=None):
|
def load_image(file, area=None):
|
||||||
"""
|
"""
|
||||||
Load an image like pillow and drop alpha channel.
|
Load an image like pillow and drop alpha channel.
|
||||||
|
|||||||
Reference in New Issue
Block a user