fix pixel button detection for rgba screenshots

This commit is contained in:
Your Name committed 2026-06-24 00:47:55 +08:00
1 parent df46d723c3
commit 61d3ad5d83
2 files changed
+48 -2

No files matched your search

+38
View File
@@ -240,11 +240,49 @@ class TestPixelButtons:
params = list(sig.parameters.keys())
assert "pic_rgb" in params or len(params) >= 1
def test_detect_attend_button_accepts_rgba_image(self):
from PIL import Image
from douyin.detection.pixel.buttons import detect_attend_button_red_area
img = Image.new("RGBA", (1080, 2400), (0, 0, 0, 255))
for x in range(200, 880):
for y in range(2000, 2120):
img.putpixel((x, y), (255, 80, 120, 255))
detected, info = detect_attend_button_red_area(
img,
return_info=True,
red_ratio_threshold=0.25,
)
assert detected is True
assert info["red_ratio"] >= 0.25
def test_detect_fansclub_join_exists(self):
from douyin.detection.pixel.buttons import detect_fansclub_join_red_area
assert callable(detect_fansclub_join_red_area)
def test_detect_fansclub_join_accepts_rgba_image(self):
from PIL import Image
from douyin.detection.pixel.buttons import detect_fansclub_join_red_area
img = Image.new("RGBA", (1080, 2400), (0, 0, 0, 255))
for x in range(200, 880):
for y in range(1940, 2140):
img.putpixel((x, y), (255, 80, 120, 255))
detected, info = detect_fansclub_join_red_area(
img,
return_info=True,
red_ratio_threshold=0.25,
)
assert detected is True
assert info["red_ratio"] >= 0.25
class TestPixelStage:
"""pixel/stage 模块测试。"""