python 多点找色_按键精灵多点找色数字识别问题

DimArr_number(9)Arr_number(0)=array("FFFFF8","1|0|FFFEF7")Arr_number(1)=array("FFFFF6","0|1|FFFFF7")Arr_number(2)=array("FFFFF5","1|-1|FFFFF4")Arr_number(3)=array("FFFFF7...

Dim Arr_number(9)

Arr_number(0) = array("FFFFF8","1|0|FFFEF7")

Arr_number(1) = array("FFFFF6","0|1|FFFFF7")

Arr_number(2) = array("FFFFF5","1|-1|FFFFF4")

Arr_number(3) = array("FFFFF7","0|-1|FFFFF4")

Arr_number(4) = array("FAF6F1","0|-1|FFFEFE,1|-2|FFFFFB")

Arr_number(5) = array("FFFFF6","0|1|FFFFF5,0|2|FFFFF7,0|3|FFFFF7")

Arr_number(6) = array("FFFFF6","0|1|FFFFF5,0|2|FFFFF7,0|3|FFFFF7")

Arr_number(7) = array("FFFFF1","0|-1|FFFFF0,0|-2|FFF6E4,1|-2|FFFFF0")

Arr_number(8) = array("FFFFF7","1|0|FFFFF9,2|1|FFFCFB,3|1|FFFFF9")

Arr_number(9) = array("FFFFF8","1|0|FFFFFB,2|1|FFFFFB,3|1|FFFFF7")

'开始判断

TracePrint GetNumber(0, 0, Plugin.Sys.GetScRX, Plugin.Sys.GetScRY, Arr_number, 0)

EndScript

'a,b,c,d 传入范围四个坐标参数

'arr 传入数字多点字符串特征的数组参数

'n 是表示每个字符的间距超过多少像素则中间以竖线隔开。例子123|456,0表示无需判断。

Function GetNumber( a, b, c, d, arr, n)

GetNumber = - 1

Dim i, temp_number_a, temp_number_c, xy, temp_number, temp_Fm, temp_txt, s, temp_arr, temp_n, temp_x

temp_number_a = a : temp_txt = - 1 : s = - 1

Do

temp_number = - 1 : temp_number_c = c

For i = 0 To UBound(arr)

temp_Fm = Plugin.Color.FindMutiColorEx(temp_number_a, b, c, d, arr(i)(0), arr(i)(1), 0.9, 0)

If temp_Fm <> "-1|-1" Then

xy = Split(temp_Fm, "|")

If temp_number = - 1 or Clng(xy(0)) < temp_number_c Then

temp_number = i : temp_number_c = Clng(xy(0))

End If

End If

Next

If temp_number = - 1 Then

If n > 0 and s > - 1 Then

GetNumber = Mid(GetNumber, 1, s) & "|" & Mid(GetNumber, s + 1, Len(GetNumber) - s)

End If

Exit Function

End If

temp_arr = Split(arr(temp_number)(1), ",")

temp_x = 0

For i = 0 To UBound(temp_arr)

temp_n = Int(Split(temp_arr(i), "|")(0))

If temp_n > temp_x Then

temp_x = temp_n

End If

Next

temp_number_a = temp_number_c + temp_x

If n > 0 Then

If temp_txt = - 1 Then

temp_txt = temp_number_a

Else

If temp_number_a - temp_txt > n Then s = Len(GetNumber)

temp_txt = temp_number_a

End If

End If

If GetNumber = - 1 Then

GetNumber = temp_number

Else

GetNumber = GetNumber * 10 + temp_number

End If

Loop

End Function

这个特征吗子太多我都删了, 传入范围怎么输入??

展开

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Python中,可以使用Pillow库来进行图像处理。多点可以通过遍历图像的每个像素点,判断该像素点的RGB值是否符合要求来实现。以下是一个简单的示例代码: ```python from PIL import Image def find_colors(image_path, colors): """ 在图像中查指定颜 :param image_path: 图像路径 :param colors: 需要查的颜列表,颜为一个元组,格式为(R, G, B) :return: 返回一个字典,键为颜元组,值为该颜在图像中出现的次数 """ image = Image.open(image_path) color_counts = {color: 0 for color in colors} for x in range(image.width): for y in range(image.height): pixel = image.getpixel((x, y)) for color in colors: if pixel == color: color_counts[color] += 1 return color_counts ``` 使用示例: ```python image_path = 'example.png' colors = [(255, 0, 0), (0, 255, 0), (0, 0, 255)] # 需要查的颜列表 color_counts = find_colors(image_path, colors) print(color_counts) # 输出:{(255, 0, 0): 10, (0, 255, 0): 20, (0, 0, 255): 30} ``` 上述代码中,我们定义了一个`find_colors`函数,该函数接受一个图像路径和需要查的颜列表作为参数,返回一个字典,键为颜元组,值为该颜在图像中出现的次数。在函数内部,我们使用`Pillow`库打开图像,然后遍历图像的每个像素点,判断该像素点的RGB值是否符合需要查的颜,如果符合,则将该颜的计数器加1。最后返回颜计数器字典。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值