Asprise-OCR下載地址:php
http://asprise.com/product/ocr/download.php?lang=csharp spa
其中須要使用的3個dll是AspriseOCR.dll、DevIL.dll、ILU.dll。圖片
須要注意的是這幾個.dll是vc寫的引用要在程序中用DllImport引用,關鍵代碼:get
[DllImport("AspriseOCR.dll", EntryPoint = "OCR", CallingConvention = CallingConvention.Cdecl)]string
public static extern IntPtr OCR(string file, int type);io
[DllImport("AspriseOCR.dll", EntryPoint = "OCRpart", CallingConvention = CallingConvention.Cdecl)]class
static extern IntPtr OCRpart(string file, int type, int startX, int startY, int width, int height);file
[DllImport("AspriseOCR.dll", EntryPoint = "OCRBarCodes", CallingConvention = CallingConvention.Cdecl)]下載
static extern IntPtr OCRBarCodes(string file, int type);引用
[DllImport("AspriseOCR.dll", EntryPoint = "OCRpartBarCodes", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr OCRpartBarCodes(string file, int type, int startX, int startY, int width, int height);
調用代碼很簡單隻有一句:
MessageBox.Show(Marshal.PtrToStringAnsi(OCRpart(img_path, -1, startX, startY, width, height)));
其中img_path:爲圖片路徑,startX、startY座標均爲0便可,width、height圖片的寬和高。