aardio 文档

process.wxOcr 库模块帮助文档

说明

参考源码: https://github.com/EEEEhex/QQImpl

此扩展库仅供技术研究测试,勿作任何不当用途。

aardio 其他 OCR 扩展库: string.ocrLite, dotNet.ocr

框选截屏 process.wxOcr.OcrResponse 对象 屏幕找字

process 成员列表 #

process.wxOcr #

微信 OCR 识别库。
只能用于界面主线程,不能用于控制台程序。

创建微信 OCR 识别对象。
只能在界面主线程创建此对象以监听微信 OCR 的多线程回调事件。

process.wxOcr() #

不指定参数则自动检测
"/WeChatOCR-Portable" 目录或微信 OCR 安装目录
并自动设定 weChatPath,ocrPath 等参数。

返回对象:ProcessWxOcrObject

process.wxOcr(weChatDir) #

指定包含了 WeChatOCR.exe , mmmojo.dll,mmmojo_64.dll 的目录。
如果这些文件都放在一个目录,只要指定一个参数就可以。

如果找不到目录返回 null。

process.wxOcr(weChatPath,ocrPath) #

可选用参数 @weChatPath 指定微信安装路径(包含 WeChat.exe 或者 mmmojo.dll 的目录)。
可选用参数 @ocrPath 指定 WeChatOCR.exe 路径。
一般不需要指定参数,默认会自动搜索并设置这些参数。

如果找不到目录返回 null

在成功创建对象以后,可以用 portable 函数复制 OCR 组件到指定目录。

全局对象 成员列表 #

mmojoOcrResponse #

微信 OCR 识别结果, protobuf.message 对象。
可用 JSON.stringify 转换为 JSON。
可用 JSON.strip 函数转换为普通表。

返回对象:processWxOcrOcrResponseObject

ProcessWxOcrObject 成员列表 #

ProcessWxOcrObject.close() #

关闭 OCR 对象。
注意在没退出此对象事件回调函数前,对象还在使用时,不能直接调用 close 函数。
可以改用 winform.setTimeout 异步调用 close 函数

ProcessWxOcrObject.mmmojoDllPath #

当前使用的 mmmojo.dll 路径。

ProcessWxOcrObject.ocrPath #

当前使用的 WeChatOCR.exe 路径。

ProcessWxOcrObject.onReadPull #

ProcessWxOcrObject.onReadPull = function(respBuffer,requestId){
    /*这里用不上,不需要指定此回调函数。  
respBuffer 为 buffer 对象,requestId 为数值。*/  
}

ProcessWxOcrObject.onReadPush #

ProcessWxOcrObject.onReadPush = function(mmojoOcrResponse){
    /*mmojoOcrResponse 为 [process.wxOcr.OcrResponse](https://www.aardio.com/zh-cn/doc/library-reference/process/wxOcr/OcrResponse.html) 对象*/
}

ProcessWxOcrObject.onReadShared #

ProcessWxOcrObject.onReadShared = function(respBuffer,requestId){
    /*这里用不上,不需要指定此回调函数。  
respBuffer 为 buffer 对象,requestId 为数值。*/
}

ProcessWxOcrObject.onRemoteConnect #

ProcessWxOcrObject.onRemoteConnect = function(isConnected){
    /*已连接,isConnected 参数表示是否连接*/
}

ProcessWxOcrObject.onRemoteDisconnect #

ProcessWxOcrObject.onRemoteDisconnect = function(){
    /*已断开,一般不需要指定此回调函数。*/
}

ProcessWxOcrObject.onRemoteMojoError #

ProcessWxOcrObject.onRemoteMojoError = function(errorBuf){
    /*这里用不上,一般不需要指定此回调函数。  
errorBuf 为 buffer 对象。*/
}

ProcessWxOcrObject.onRemoteProcessLaunchFailed #

ProcessWxOcrObject.onRemoteProcessLaunchFailed = function(errorCode){
    /*忽略这里用不上,一般不需要指定此回调函数。  
errorCode 为错误代码,数值。*/
}

ProcessWxOcrObject.onRemoteProcessLaunched #

ProcessWxOcrObject.onRemoteProcessLaunched = function(){
    /*忽略这里用不上,不需要指定此回调函数。*/
}

ProcessWxOcrObject.portable(输出目录) #

提取 OCR 组件绿化独立版到指定目录(默认为 "/WeChatOCR-Portable")。

ProcessWxOcrObject.sendRquest(files,callback) #

ProcessWxOcrObject.sendRquest(/*发送识别图象请求。  
参数 @file 可指定一个或多个文件路径参数,  
也可以传入一个包含多个文件数据的数组。  
可选用最后一个 @callback 参数指定接收识别结果的回调函数。*/  
    function(mmojoOcrResponse){  

            /*识别结果 mmojoOcrResponse 为 process.wxOcr.OcrResponse 对象。*/  
            var singleResult = mmojoOcrResponse.ocrResult.singleResult;  

            /*逐行输出到文本框*/  
            for(k,sr in singleResult){  
                /*sr 对象的 lx,ly 为左上角坐标,rx,ry 为右下角坐标*/  
                winform.edit.print(sr.singleStrUtf8)  
            }         
    }  
)

Markdown 格式