Add shopping red packet detection tests and sample image

- Implemented a test script for shopping red packet detection using pixel analysis and OCR.
- Created a sample image to simulate a shopping red packet for testing purposes.
- Added functions to test pixel detection, coordinate definitions, and OCR keyword matching.
- Included detailed print statements for test results and summaries.
This commit is contained in:
Your Name committed 2026-01-08 20:37:49 +08:00
1 parent b3011dd9ce
commit fb0c07c91a
30 files changed
+1269 -319

No files matched your search

+11 -2
View File
@@ -5,8 +5,10 @@
"""
import sys
import os
sys.path.insert(0, os.path.dirname(__file__))
# 模拟 analyser 对象
class MockAnalyser:
def __init__(self):
@@ -24,13 +26,17 @@ class MockAnalyser:
def _scale_from_base(self, x, y):
return x, y
def _capture_roi_screenshot(self, roi_label, sx, sy, roi_px, shared_screenshot_path):
def _capture_roi_screenshot(
self, roi_label, sx, sy, roi_px, shared_screenshot_path
):
print(f"[测试] 截图 ROI: {roi_label} at ({sx}, {sy}) size {roi_px}")
return f"/tmp/test_roi_{roi_label}.png"
# 导入测试函数
from douyin.other.douyin_yanghao import yanghao_idle
def test_detect_icon():
"""测试 _detect_icon 函数"""
print("=== 测试 _detect_icon 函数 ===")
@@ -55,6 +61,7 @@ def test_detect_icon():
print("✅ _detect_icon 函数测试完成")
def test_yanghao_idle():
"""测试 yanghao_idle 函数(简化版)"""
print("\n=== 测试 yanghao_idle 函数 ===")
@@ -82,6 +89,7 @@ def test_yanghao_idle():
except Exception as e:
print(f"❌ yanghao_idle 函数测试失败: {e}")
class MockOperation:
def click(self, device_id, x, y):
print(f"[测试] 点击设备 {device_id} 坐标 ({x}, {y})")
@@ -92,7 +100,8 @@ class MockOperation:
def get_screenshot(self, device_id, use_service=False):
print(f"[测试] 获取设备 {device_id} 截图")
if __name__ == "__main__":
test_detect_icon()
test_yanghao_idle()
print("\n🎉 所有测试完成!")
print("\n🎉 所有测试完成!")