mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-12 08:38:20 +08:00
Dev: Fix button_extract.py
This commit is contained in:
@@ -492,6 +492,23 @@ def get_color(image, area):
|
||||
return color[:3]
|
||||
|
||||
|
||||
def get_bbox(image):
|
||||
"""
|
||||
A numpy implementation of the getbbox() in pillow.
|
||||
|
||||
Args:
|
||||
image (np.ndarray): Screenshot.
|
||||
|
||||
Returns:
|
||||
tuple: (upper_left_x, upper_left_y, bottom_right_x, bottom_right_y)
|
||||
"""
|
||||
if image_channel(image) == 3:
|
||||
image = np.max(image, axis=2)
|
||||
x = np.where(np.max(image, axis=0) > 0)[0]
|
||||
y = np.where(np.max(image, axis=1) > 0)[0]
|
||||
return (x[0], y[0], x[-1] + 1, y[-1] + 1)
|
||||
|
||||
|
||||
def color_similarity(color1, color2):
|
||||
"""
|
||||
Args:
|
||||
|
||||
Reference in New Issue
Block a user