飞浆识别端下载地址:[老狼][资源分享]----PC本地文字识别收录贴(支持模拟器)----被峨眉山猴子暴打的第七天(27)识别效果一览:源码下载:[涉及知识点Post、文件转B64、Unicode编码转文字、正则]TracePrint PC识别(1, 1, 200, 200)
TracePrint PC识别(1, 200, 400, 400)
Function PC识别(x1, y1, x2, y2)
Dim 路径,PC识别
路径 = "C:\Ocr.bmp"
Call Plugin.Pic.PrintScreen(x1, y1, x2, y2, 路径)
Delay 200
PC识别 =__HttpPost("http://120.79.180.223:19811/ocr_data_2", __转Base64(路径))
End Function
Function __转Base64(图像地址)
Dim dr
Set dr = CreateObject("ADODB.Stream")
With dr
.Mode = 3
.Type = 1
.open
.LoadFromFile 图像地址
File_Stream = .Read
.Close
End With
Set dr = Nothing
Dim xml_dom, Node
Set xml_dom = CreateObject("Microsoft.XMLDOM")
xml_dom.loadXML ("")
Set Node = xml_dom.createElement("HTML")
With Node
.dataType = "bin.base64"
.nodeTypedValue = File_Stream
__转Base64 = .Text
End With
Set Node = Nothing
Set xml_dom = Nothing
End Function
Function __HttpPost(posturl,params)
Dim oauth_http
Set oauth_http = CreateObject("Msxml2.ServerXMLHTTP")
oauth_http.SetOption 2, 13056
oauth_http.Open "
OST", posturl, False, "", ""
oauth_http.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oauth_http.Send (params)
If oauth_http.Status = "200" Then
__HttpPost = __Unicode编码转文字(oauth_http.responseText)
Else
__HttpPost = ""
End If
Set oauth_http=nothing
End Function
Function __Unicode编码转文字(编码内容)
编码内容 = LCase(编码内容)
Unicode编码转文字 = ""
Dim regEx, Matches
Set regEx = New RegExp
regEx.Pattern ="\\u"
regEx.[Global] = True
regEx.IgnoreCase = False
编码内容 = regEx.Replace(编码内容, "&H")//将/u替换为&H
regEx.Pattern ="&H.+?\b"
Set Matches = regEx.Execute(编码内容) //将每个字的编码搜索出来
For Each Match In Matches
编码内容=Replace(编码内容, Match,Eval("ChrW(" & Match & ")"))
Next
__Unicode编码转文字= 编码内容
End Function