验证码识别支持库(aspriseOCR for AAuto)
下载源码:
http://dl.dbank.com/c0ueqf213m
一般验证码准确率100%
在工程中添加aspriseOCR支持库:
使用范例:
库源码:
http://dl.dbank.com/c0ueqf213m
一般验证码准确率100%
在工程中添加aspriseOCR支持库:
第一步:
请将工程里的lib目录覆盖到你的AAuto工程lib目录.
第二步:
右键点击工程中的用户库,在弹出菜单中点击"刷新目录,智能提示"
使用范例:
import inet.http;
import aspriseOCR;
getImage = function(url,file){
var http = inet.http();
var str = http.get(url)
string.save(file, str)
return file;
}
//识别网络验证码
var str = aspriseOCR.ocr(
getImage("http://www.*****.com/Imgchk/validatecode.asp"
,"/test.bmp")
)
io.open()
io.print("识别验证码成功",str);
execute("pause") //按任意键继续
io.close();//关闭控制台
库源码:
import fsys;
namespace aspriseOCR;
if( ! ..io.exist("\lib\aspriseOCR\.dll\DevIL.dll",2) ){
..fsys.createDir("\lib\aspriseOCR\.dll\")
..string.save("\lib\aspriseOCR\.dll\DevIL.dll", $"\lib\aspriseOCR\.dll\DevIL.dll")
..string.save("\lib\aspriseOCR\.dll\ILU.dll", $"\lib\aspriseOCR\.dll\ILU.dll")
}
var DevIL = ..raw.loadDll( "\lib\aspriseOCR\.dll\DevIL.dll" )
var ILU = ..raw.loadDll( "\lib\aspriseOCR\.dll\ILU.dll" )
var AspriseOCR = ..raw.loadDll( $"\lib\aspriseOCR\.dll\AspriseOCR.dll" )
var OCR = AspriseOCR.api("OCR","string(string file,int imageType)","cdcel")
var OCRBarCodes = AspriseOCR.api("OCRBarCodes","string(string file,int imageType)","cdcel")
var OCRpart = AspriseOCR.api("OCRpart","string(string file,int imageType,int startX,int startY,int width,int height)","cdcel")
var OCRpartBarCodes = AspriseOCR.api("OCRpartBarCodes","string(string file,int imageType,int startX,int startY,int width,int height)","cdcel")
var imageType = {
["jpg"]=1061;
["jpeg"]=1061;
["pxr"]=1085;
["xpm"]=1086;
["ico"]=1060;
["pic"]=1065;
["mdl"]=1073;
["pcd"]=1063;
["exif"]=1082;
["cut"]=1057;
["chead"]=1071;
["dcx"]=1080;
["lbm"]=1062;
["tif"]=1070;
["tiff"]=1070;
["dds"]=1079;
["raw"]=1072;
["tga"]=1069;
["jng"]=1077;
["sgi"]=1068;
["pnm"]=1067;
["pbm"]=1067;
["png"]=1066;
["lif"]=1076;
["pix"]=1084;
["psp"]=1083;
["doom"]=1058;
["gif"]=1078;
["psd"]=1081;
["wal"]=1074;
["pcx"]=1064;
["bmp"]=1056;
["*"]=-1
}
import inet.http;
ocr = function(file,ext="*"){
ext = ..string.lower(ext)
file = ..io.fullpath(file)
return OCR(file,imageType[ext]);
}
ocrBarCodes = function(file,ext="*"){
ext = ..string.lower(ext)
file = ..io.fullpath(file)
return OCRBarCodes(file,imageType[ext]);
}
ocrPart = function(file,x=0,y=0,width=32,height=32,ext="*"){
ext = ..string.lower(ext)
file = ..io.fullpath(file)
return OCRpart(file,imageType[ext],x,y,width,height);
}
ocrPartBarCodes = function(file,x=0,y=0,width=32,height=32,ext="*"){
ext = ..string.lower(ext)
file = ..io.fullpath(file)
return OCRpartBarCodes(file,imageType[ext],x,y,width,height);
}
/**intellisense(aspriseOCR)
ocr("__") = 识别图像文本,参数指定图像文件路径\n自动识别图像类型
ocr("__","jpg") = 识别图像文本,参数指定图像文件路径\n参数指定图像类型
ocrBarCodes("__") = 识别图像条码,参数指定图像文件路径\n自动识别图像类型
ocrBarCodes("__","jpg") = 识别图像条码,参数指定图像文件路径\n参数指定图像类型
ocrPart(.(文件路径,x坐标,y坐标,宽,高,图像类型) = 识别图像文本,图像类型使用后缀名指定(可选参数)
ocrPartBarCodes(.(文件路径,x坐标,y坐标,宽,高,图像类型) = 识别图像条码,图像类型使用后缀名指定(可选参数)
end intellisense**/
原文地址:http://www.aau.cn/thread-2099-1-1.html