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

+5 -20
View File
@@ -657,9 +657,8 @@ class underlying_operations:
dur = (time_module.time() - start_ts) * 1000.0
logging.info(
"[截图] 总耗时(ms)=%.1f device=%s use_service=%s result=%s",
"[截图] 总耗时(ms)=%.1f use_service=%s result=%s",
dur,
device_id,
bool(use_service),
final_result,
)
@@ -842,9 +841,8 @@ class underlying_operations:
adb_subprocess_dur = (time_module.time() - adb_start) * 1000.0
logging.info(
"[截图] ADB exec-out subprocess耗时(ms)=%.1f device=%s attempt=%d",
"[截图] ADB exec-out subprocess耗时(ms)=%.1f attempt=%d",
adb_subprocess_dur,
device_id,
attempt + 1,
)
@@ -912,22 +910,10 @@ class underlying_operations:
overall_dur = (
time_module.time() - overall_start
) * 1000.0
# 记录分阶段耗时汇总,便于排查瓶颈(JSON-like)
# 记录总耗时
logging.info(
"[截图汇总] device=%s total_ms=%.1f cleanup_ms=%.1f adb_execout_ms=%.1f validate_tmp_ms=%.1f replace_ms=%.1f mirror_ms=%.1f validate_out_ms=%.1f",
device_id,
"[截图] _get_screenshot_direct总耗时(ms)=%.1f (exec-out成功)",
overall_dur,
cleanup_dur,
adb_subprocess_dur,
validate_tmp_dur,
replace_dur,
mirror_dur,
validate_out_dur,
)
logging.info(
"[截图] _get_screenshot_direct总耗时(ms)=%.1f device=%s (exec-out成功)",
overall_dur,
device_id,
)
print(
f"[{timetag}] [截图] ✓ 获取屏幕截图成功"
@@ -1064,9 +1050,8 @@ class underlying_operations:
time_module.time() - fallback_start
) * 1000.0
logging.info(
"[截图] _get_screenshot_direct总耗时(ms)=%.1f device=%s (回退方案成功, 回退部分耗时=%.1fms)",
"[截图] _get_screenshot_direct总耗时(ms)=%.1f (回退方案成功, 回退部分耗时=%.1fms)",
overall_dur,
device_id,
fallback_total_dur,
)
print("{} 获取屏幕截图".format(timetag))