get("#348") -- rgb and bright get("#137") -- split x, y, w, h = img.width+109-300, img.height+62-83, 21, 21 print("x2:", x+w, "y2:", y+h, "width, height:", img.width, img.height) if x < 0 or y < 0 or x+w > img.width or y+h > img.height then return "No Aibo" end aibo = [[ WWWWWWWWWWWWWWWWWWWWW WWWW????????OOWWWWWWW WWWW????????OZOWWWWWW WWWW????????OZZOWWWWW WWWW????????OZPZOWWWW WWWW????????OZRPZOOOO WWWW????????OZTRPZZZZ ????????????OZTTPZZZZ ????????????WOZTZZZZZ ????????OOOOWWOZZZZZZ ???????OZZZZOWOZ????? WWWW??OZZZZYTOXZ????? WWWW?OZZZZXTZOWZ????? WWWWPWZZZZXYZOTYZZZZX WWWWOWZZZZZZZVOVXXZXU WWWWOXZWZZZZZVVOUXZZA WWWWOXZVZZZZZOVVOTZZA WWWWOXZVZZZZZZOVSOXXX WWWWOXZRYZYYZZZOOAUUA WWWWOWZPVXSXZZZZXXAAO WWWWOYZVQURYZXXZYXXAO ]] aibo = split(aibo, "\n") total, count = 0, 0 for yy=y, y+h-1 do s = "" line = aibo[yy-y+1] for xx=x, x+w-1 do pix = img.getInt(xx, yy) --s = s..num2hex(pix, 6).." " --s = s..(isBright(pix) and "*" or ".") c = line:sub(xx-x+1, xx-x+1) if c ~= '?' then b = math.floor(bright(rgb(pix))*25+0.5) --print("c", c) lb = string.byte(c)-string.byte("A") diff = math.abs(b-lb) s = s..string.char(string.byte("A")+diff) total = total+diff count = count+1 else s = s.."?" end end print(s) end sim = math.floor(100*(1-total/(count*25))+0.5) print("Aibo similarity: "..sim.."%") if sim >= 99 then return "Aibo: "..x..", "..y..", "..x+w..", "..y+h else return "No Aibo" end