颜色数量
from ascript.ios.screen import CountingColor
从屏幕中找到指定颜色的数量
方法
统计颜色数量
CountingColor.count(colors, rect=None, sim=1)
- 参数
| 参数 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| colors | str | 是 | 颜色参数,用图色工具生成 |
| rect | list | 否 | 圈定屏幕范围 |
| sim | float | 否 | 相似度 0.0~1.0,默认1(完全匹配) |
| bitmap | PIL.Image | 否 | 要识别的图片,默认全屏幕截图 |
- 返回值
int 符合条件的颜色像素数量
- 示例
from ascript.ios.screen import CountingColor
res = CountingColor.count("#EEF0B9|#FFFFFF|#46332D|#A0847B")
print(res)
# 指定区域和相似度
res = CountingColor.count("#FF0000", rect=[0, 0, 500, 500], sim=0.95)
print(res)