日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > C# >内容正文

C#

C# OCR AspriseOcr测试使用图像文字中英文识别

發布時間:2023/12/14 C# 50 豆豆
生活随笔 收集整理的這篇文章主要介紹了 C# OCR AspriseOcr测试使用图像文字中英文识别 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

OCR AspriseOcr測試使用中英文識別:因為使用AspriseOcr是需要商業授權碼的,故使用網上破解dll包進行測試,測試的結果并不理想,可能是因為版本太低所致。如果真的需要做好OCR應用建議購買其授權碼。

官網地址:http://asprise.com/

應用場景

  • 圖像掃描:對圖片進行文字識別
  • 文件掃描:對PDF文件進行文字識別
  • 條碼掃描:對二維碼條碼進行掃描識別

測試示例

注意:需要下載的DLL分別是AspriseOCR.dll、DevIL.dll、ILU.dll將其放在生成的bin/Debug生成目錄下,然后就可以測試了,網上有人說需要.net 2.0這個是謬傳,我用的是.net framwork 4.5 ,DLL包不用放在注冊表里去,放在可執行目錄即可,程序運行時會自動加載,因為使用的是DllImport方式導入。

定義接口:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;namespace OCR {interface ImageRecognitionInterface{/// <summary>/// 識別圖像/// </summary>/// <param name="imgPath"></param>/// <returns></returns>string Recognize(string imgPath);} }

編寫工具類和實現:

using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks;namespace OCR.ImageRecognition {/// <summary>/// AspriseOCR/// </summary>/// DLL包引用:AspriseOCR.dll、DevIL.dll、ILU.dll/// 下載地址:http://asprise.com/product/ocr/download.php?lang=csharppublic class AspriseOCR:ImageRecognitionInterface{[DllImport("AspriseOCR.dll", EntryPoint = "OCR", CallingConvention = CallingConvention.Cdecl)]public static extern IntPtr OCR(string file, int type);[DllImport("AspriseOCR.dll", EntryPoint = "OCRpart", CallingConvention = CallingConvention.Cdecl)]static extern IntPtr OCRpart(string file, int type, int startX, int startY, int width, int height);[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);/// <summary>/// 識別圖像/// </summary>/// <param name="imgPath"></param>/// <returns></returns>public string Recognize(string imgPath){try{int startX = 0, startY = 0;Image image = Image.FromFile(imgPath);return Marshal.PtrToStringAnsi(OCRpart(imgPath, -1, startX, startY, image.Width, image.Height));}catch (Exception ex){Console.WriteLine("識別圖像錯誤:"+ex.Message);}return "";}} }

測試效果

這里通過解析中英文能力來測試

英文識別

中文識別

可見,效果不是很理想,還是要購買其正規渠道的產品才行。

示例和包下載

網上的分比較貴,不建議去下載,因為沒什么用,我這里分享一個大家可以做測試使用。

鏈接:https://pan.baidu.com/s/1Lo3lSnHVvYCfDp-tf9oLnQ

密碼:fmai

AspriseOcr也支持Java圖像識別:參考http://zxs19861202.iteye.com/blog/1749780

總結

以上是生活随笔為你收集整理的C# OCR AspriseOcr测试使用图像文字中英文识别的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。