Skip to main content

颜色数量

from ascript.ios.screen import CountingColor

从屏幕中找到指定颜色的数量

方法

统计颜色数量

CountingColor.count(colors, rect=None, sim=1)
  • 参数
参数类型是否必填说明
colorsstr颜色参数,用图色工具生成
rectlist圈定屏幕范围
simfloat相似度 0.0~1.0,默认1(完全匹配)
bitmapPIL.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)