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**/