国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

C# 圖片識別(支持21種語言)

2019-11-08 03:00:54
字體:
供稿:網(wǎng)友

原文鏈接 http://www.cnblogs.com/stone_w/archive/2011/10/08/2202397.html#2472415

圖片識別的技術(shù)到幾天已經(jīng)很成熟了,只是相關(guān)的資料很少,為了方便在此匯總一下(C#實現(xiàn)),方便需要的朋友查閱,也給自己做個記號。

圖片識別的用途:很多人用它去破解網(wǎng)站的驗證碼,用于達(dá)到自動刷票或者是批量注冊的目的,但我覺得它最吸引我的地方是可以讓一些書寫的東西,自動識別成電腦上的文字,比如說手?jǐn)M的合同,修改過的書面論文或者是文檔,每月的花費發(fā)票需要在電腦上錄入或者是匯總信息,日記本上的文章要轉(zhuǎn)移到電腦上等等,我們現(xiàn)在就不用再頭痛把它們在電腦上敲寫一遍了。 這里寫圖片描述

本文介紹兩種比較主流和成熟的識別方式: 方式一、asprise-OCR實現(xiàn)。 方式二、Microsoft Office Document Imaging(Office 2007) 組件實現(xiàn)。

方式一、AsPRise-OCR的使用。 Asprise-OCR下載地址: http://asprise.com/product/ocr/download.php?lang=csharp 其中需要使用的3個dll是AspriSEOCR.dll、DevIL.dll、ILU.dll。 需要注意的是這幾個.dll是vc寫的引用要在程序中用DllImport引用,關(guān)鍵代碼: [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);

調(diào)用代碼很簡單只有一句: MessageBox.Show(Marshal.PtrToStringAnsi(OCRpart(img_path, -1, startX, startY, width, height))); 其中img_path:為圖片路徑,startX、startY坐標(biāo)均為0即可,width、height圖片的寬和高。

方式二、Microsoft Office Document Imaging(Office 2007) 組件實現(xiàn)。 在使用之前需要給大家說的是Imaging 組件的兼容性不是很好,使用win 7 office 2007的時必須打上office 2007 sp1或者sp2補(bǔ)丁,讀取中文才行。 sp1補(bǔ)丁地址(226M) : http://download.microsoft.com/download/1/6/5/1659d607-8696-4001-8072-efaedd70dd30/office2007sp1-kb936982-fullfile-zh-cn.exe sp2補(bǔ)丁地址(301 MB): http://download.microsoft.com/download/A/3/9/A39E919E-AFA8-4128-9249-51629206C70F/office2007sp2-kb953195-fullfile-zh-cn.exe

給項目添加組件引用,如圖: 這里寫圖片描述

使用代碼: MODI.Document doc = new MODI.Document(); doc.Create(img_Path); MODI.Image image; MODI.Layout layout; doc.OCR(MODI.MiLANGUAGES.miLANG_CHINESE_SIMPLIFIED, true, true); // 識別簡體中文 for (int i = 0; i < doc.Images.Count; i++) { image = (MODI.Image)doc.Images[i]; layout = image.Layout; sb.Append(layout.Text); } MessageBox.Show(sb.ToString()); 其中img_Path為圖片路徑,MODI.MiLANGUAGES為讀取圖片的文字類型枚舉。

本文源碼下載地址:http://files.cnblogs.com/stone_w/OCR.rar

漢王 PDF OCR V8.1簡體中文版下載地址(已經(jīng)使用了,感覺不錯推薦一下):http://xiazai.zol.com.cn/detail/34/335364.shtml


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 锦屏县| 抚远县| 延安市| 芦山县| 芦溪县| 麻阳| 平乐县| 格尔木市| 珠海市| 贵定县| 柳州市| 桓台县| 绍兴市| 澜沧| 连云港市| 林口县| 赤壁市| 通辽市| 佛坪县| 稻城县| 林西县| 麻城市| 高州市| 万山特区| 阜新| 南昌县| 岳阳县| 新邵县| 彭泽县| 安平县| 梁山县| 马鞍山市| 泰州市| 赤峰市| 溆浦县| 任丘市| 逊克县| 成安县| 文化| 阿荣旗| 佛学|