求高手帮忙重新封装改写这个函数:x, y = findMultiColorInRegionFuzzy,
改写后可以使用触动的取色格式,例如:(0x181F85, "29|1|0x00BBFE,103|-4| 0x0B6BBE,65|9|0x150972", 100, 0, 0, 639, 959)
或者能提供一下触动关于这个函数的封装源码也行
function findColorPro(first,color,sim,x1,y1,x2,y2)
local Arr = {}
local colorArr = Split(color,",")
table.insert(Arr,first)
for k,v in pairs(colorArr) do
local colorArrs = Split(v,"|")
for k2,v2 in pairs(colorArrs) do
table.insert(Arr,tonumber(v2))
end
end
x, y = findMultiColorInRegionFuzzy(Arr,sim,x1,y1,x2,y2)
if x ~= -1 and y ~= -1 then
return true
else
return false
end
end
function Split(szFullString, szSeparator)
local nFindStartIndex = 1
local nSplitIndex = 1
local nSplitArray = {}
while true do
local nFindLastIndex = string.find(szFullString, szSeparator, nFindStartIndex)
if not nFindLastIndex then
nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, string.len(szFullString))
break
end
nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, nFindLastIndex - 1)
nFindStartIndex = nFindLastIndex + string.len(szSeparator)
nSplitIndex = nSplitIndex + 1
end
return nSplitArray
end
function main()
if findColorPro(0x181F85, "29|1|0x00BBFE,103|-4| 0x0B6BBE,65|9|0x150972", 100, 0, 0, 639, 959) then
notifyMessage("yes");
else
notifyMessage("no");
end
end
能写二值化处理图片并输出吗?