发帖
充值
 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
26 1

毫秒级快速找字OCR识别文字API接口比肩百度AI

源码分享 18028 26 2021-11-23 00:02:41
本帖最后由 flk100207 于 2021-12-24 14:06 编辑

function  识别原文字本地(IP地址,左,上,右,下,查找文字,是否点击,精准找字,语言,模式)
        --local b64 = 类_服务.识别原文字本地("http://110.40.196.160:5689",265,350,451,400)
        --local b64 = 类_服务.识别原文字本地("http://110.40.196.160:5689",265,350,451,400,"设置",true)
        --语言----日=japan  中=ch 韩=korean  英=en
        --模式----模式一=h  模式二=m
        if 语言 == nil or 语言 == 0 then 语言="ch" end
        if 查找文字 == "" or 查找文字 == 0 then 查找文字 = nil end
    if 模式 == nil or 模式 == 0 then 模式="m" end
        snapShot("/storage/emulated/0/test.png",左,上,右,下)
        local b64 = getFileBase64("/storage/emulated/0/test.png")
        b64 = encodeUrl(b64)
        local formStr = "img=" .. b64 .. "&lan=" .. 语言 .. "&model="..模式.."&rotate=0"
        b64 = httpPost(IP地址.."/report?",formStr)
        --print(b64)
        b64 = string.gsub(b64, "\n","")
        b64 = string.gsub(b64, " ","")
        b64 = string.gsub(b64, '","',"|")
        b64 = string.gsub(b64, '"',"")
        b64 = splitStr(b64,":[")
        local 数组={}
        local pxt,pxx,pxy
        if #b64 >= 2 then
                b64 = splitStr(b64[2],"]")
                if #b64 >= 2 then
                        b64 = splitStr(b64[1],"},{")
                        for pxwzs=1,#b64 do
                                --print(b64[pxwzs])
                                pxt = string.match(b64[pxwzs], "content:".."(.-)".."|")
                                if 查找文字 ~= nil then
                                        if 精准找字 then
                                                if pxt ==  查找文字 then
                                                        if 是否点击 then
                                                                pxx= string.match(b64[pxwzs], "ind_x1:".."(.-)".."|")
                                                                pxy= string.match(b64[pxwzs], "ind_y1:".."(.-)".."|")
                                                                pxx = splitStr(pxx,",")
                                                                pxy = splitStr(pxy,",")
                                                                tap(math.floor((tonumber(pxy[1])-tonumber(pxx[1]))/2+tonumber(pxx[1])+左),math.floor((tonumber(pxy[2])-tonumber(pxx[2]))/2+tonumber(pxx[2])+上))
                                                        end
                                                        return true
                                                end
                                        else
                                                if  string.find(pxt,查找文字) ~= nil then
                                                        if 是否点击 then
                                                                pxx= string.match(b64[pxwzs], "ind_x1:".."(.-)".."|")
                                                                pxy= string.match(b64[pxwzs], "ind_y1:".."(.-)".."|")
                                                                pxx = splitStr(pxx,",")
                                                                pxy = splitStr(pxy,",")
                                                                tap(math.floor((tonumber(pxy[1])-tonumber(pxx[1]))/2+tonumber(pxx[1])+左),math.floor((tonumber(pxy[2])-tonumber(pxx[2]))/2+tonumber(pxx[2])+上))
                                                        end
                                                        return true
                                                end
                                        end
                                else
                                        pxx= string.match(b64[pxwzs], "ind_x1:".."(.-)".."|")
                                        pxy= string.match(b64[pxwzs], "ind_y1:".."(.-)".."|")
                                        pxx = splitStr(pxx,",")
                                        pxy = splitStr(pxy,",")
                                        数组[pxwzs]={
                                        text = pxt ,
                                        l = tonumber(pxx[1])+左 ,
                                        t = tonumber(pxx[2])+上 ,
                                        r = tonumber(pxy[1])+左 ,
                                        b = tonumber(pxy[2])+上 ,
                                        x = math.floor((tonumber(pxy[1])-tonumber(pxx[1]))/2+tonumber(pxx[1])+左) ,
                                        y = math.floor((tonumber(pxy[2])-tonumber(pxx[2]))/2+tonumber(pxx[2])+上)
                                        }
                                end
                        end
                        if 查找文字 ~= nil then
                                return false
                        else
                                return  数组
                        end
                end
        end
end

local tick = tickCount()
aa=识别原文字本地("http://110.40.196.160:5678",0,0,720,1280)
if #aa >= 1 then
        print(aa)
        for v=1,#aa do
                print(aa[v])
        end
end
print("遍历速度:"..tickCount()-tick)

local tick = tickCount()
if 识别原文字本地("http://110.40.196.160:5689",0,0,720,1280,"脚本列表",true,true) then
        print("找到文字")
else
        print("没找到文字")
end
print("找字速度:"..tickCount()-tick)
--IP端口均为临时体验,如需服务端自行进群下载

点击链接加入群聊【OCR】:https://jq.qq.com/?_wv=1027&k=JfIHeBpJ


使用道具 举报

感觉好厉害,备份下,
2021-11-24 09:28:42
学习学习,好牛逼的样子
2021-11-24 09:47:46
attempt to get length of a nil value (global 'aa')
2021-11-24 16:27:29
大佬 这个那里是不是有 点不对啊 post 提交之后 没返回啊 为print  不显示
2021-11-24 19:39:07
用不了0.0
2021-11-24 23:02:08

不可能不可能不可能不可能
2021-11-25 00:13:48
哈哈哈用不了--
2021-11-30 11:19:13
支持支持支持
2021-11-30 20:50:53
不会用,先来学习
您需要登录后才可以回帖 立即登录
高级模式
123下一页
源码分享