- Updated `config.json` to introduce new settings for infinite loop mode and adjust various thresholds for 福袋 detection. - Refined the pixel detection logic in `douyin_detection.py` to improve error handling and retry mechanisms. - Enhanced reservation handling in `douyin_flow_control.py` to prioritize high-value 福袋 and streamline the switching process. - Improved the GUI in `gui_app.py` to support new configuration options and ensure better user experience. - Added new tools for analyzing 福袋 colors and comparing them with coupon colors to aid in detection accuracy. - Updated documentation to reflect changes in configuration and usage instructions.
84 lines
3.3 KiB
Python
84 lines
3.3 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""对比福袋和优惠券的RGB颜色,找出区分特征"""
|
|
|
|
from PIL import Image
|
|
from collections import Counter
|
|
|
|
print("=" * 60)
|
|
print("福袋图标颜色分析")
|
|
print("=" * 60)
|
|
fudai = Image.open('assets/fudai.png').convert('RGB')
|
|
fudai_pixels = [(r,g,b) for y in range(fudai.height) for x in range(fudai.width)
|
|
for r,g,b in [fudai.getpixel((x,y))] if not (r<30 and g<30 and b<30)]
|
|
fudai_colors = Counter(fudai_pixels)
|
|
fudai_top = fudai_colors.most_common(5)
|
|
print("Top 5 colors:")
|
|
for (r,g,b), count in fudai_top:
|
|
print(f" RGB({r:3d}, {g:3d}, {b:3d}) - {count/len(fudai_pixels)*100:5.2f}%")
|
|
|
|
fudai_r = [p[0] for p in fudai_pixels]
|
|
fudai_g = [p[1] for p in fudai_pixels]
|
|
fudai_b = [p[2] for p in fudai_pixels]
|
|
print(f"\nRGB range: R[{min(fudai_r)}-{max(fudai_r)}] G[{min(fudai_g)}-{max(fudai_g)}] B[{min(fudai_b)}-{max(fudai_b)}]")
|
|
|
|
print("\n" + "=" * 60)
|
|
print("优惠券颜色分析")
|
|
print("=" * 60)
|
|
coupon = Image.open('assets/coupon.png').convert('RGB')
|
|
coupon_pixels = [(r,g,b) for y in range(coupon.height) for x in range(coupon.width)
|
|
for r,g,b in [coupon.getpixel((x,y))] if not (r<30 and g<30 and b<30)]
|
|
coupon_colors = Counter(coupon_pixels)
|
|
coupon_top = coupon_colors.most_common(5)
|
|
print("Top 5 colors:")
|
|
for (r,g,b), count in coupon_top:
|
|
print(f" RGB({r:3d}, {g:3d}, {b:3d}) - {count/len(coupon_pixels)*100:5.2f}%")
|
|
|
|
coupon_r = [p[0] for p in coupon_pixels]
|
|
coupon_g = [p[1] for p in coupon_pixels]
|
|
coupon_b = [p[2] for p in coupon_pixels]
|
|
print(f"\nRGB range: R[{min(coupon_r)}-{max(coupon_r)}] G[{min(coupon_g)}-{max(coupon_g)}] B[{min(coupon_b)}-{max(coupon_b)}]")
|
|
|
|
print("\n" + "=" * 60)
|
|
print("区分特征分析")
|
|
print("=" * 60)
|
|
|
|
# 优惠券的主要红色特征
|
|
coupon_red = [p for p in coupon_pixels if p[0] > 250 and p[1] < 100 and p[2] < 120]
|
|
if coupon_red:
|
|
red_r = [p[0] for p in coupon_red]
|
|
red_g = [p[1] for p in coupon_red]
|
|
red_b = [p[2] for p in coupon_red]
|
|
print(f"\n优惠券红色区域:")
|
|
print(f" R: {min(red_r)}-{max(red_r)}")
|
|
print(f" G: {min(red_g)}-{max(red_g)}")
|
|
print(f" B: {min(red_b)}-{max(red_b)}")
|
|
print(f" 特征: 高R值(>{min(red_r)}),低G值(<{max(red_g)}),低B值(<{max(red_b)})")
|
|
|
|
# 福袋的主要颜色特征
|
|
fudai_pink = [p for p in fudai_pixels if p[0] > 225 and p[1] > 180 and p[2] > 190]
|
|
if fudai_pink:
|
|
pink_r = [p[0] for p in fudai_pink]
|
|
pink_g = [p[1] for p in fudai_pink]
|
|
pink_b = [p[2] for p in fudai_pink]
|
|
print(f"\n福袋粉红色区域:")
|
|
print(f" R: {min(pink_r)}-{max(pink_r)}")
|
|
print(f" G: {min(pink_g)}-{max(pink_g)}")
|
|
print(f" B: {min(pink_b)}-{max(pink_b)}")
|
|
print(f" 特征: 高R值(>{min(pink_r)}),高G值(>{min(pink_g)}),高B值(>{min(pink_b)})")
|
|
|
|
print("\n" + "=" * 60)
|
|
print("建议的排除条件")
|
|
print("=" * 60)
|
|
print("\n优惠券红色特征(需要排除):")
|
|
print(" - R > 250 且 G < 100 且 B < 120 (鲜艳红色)")
|
|
print(" - R > 250 且 G < 150 且 B < 150 (较宽松的红色)")
|
|
print("\n福袋粉红色特征(需要保留):")
|
|
print(" - R > 225 且 G > 180 且 B > 190 (粉红色)")
|
|
print("\n建议的福袋检测条件:")
|
|
print(" R > 225 and R <= 255")
|
|
print(" G > 180 and G <= 255")
|
|
print(" B > 190 and B <= 255")
|
|
print(" AND NOT (R > 250 and G < 100 and B < 120) # 排除优惠券红色")
|
|
|