halcon與C#混合編程(三)數(shù)字識(shí)別_第1頁(yè)
halcon與C#混合編程(三)數(shù)字識(shí)別_第2頁(yè)
halcon與C#混合編程(三)數(shù)字識(shí)別_第3頁(yè)
halcon與C#混合編程(三)數(shù)字識(shí)別_第4頁(yè)
halcon與C#混合編程(三)數(shù)字識(shí)別_第5頁(yè)
已閱讀5頁(yè),還剩2頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、示例:數(shù)字識(shí)別要識(shí)別的圖片:halcon 源碼:1:*讀取圖片2: read_image(Image,'D:/My數(shù)字識(shí)別/l.jpg')3:4: *圖像處理5: decompose3(Image,ImageR,ImageG,ImageB)6: threshold(ImageG,Regions,0,183)7: connection(Regions,Connection)1987.72,8:9: select_shape(Connection,SelectedRegions,'area','and7500)10:11: read_ocr_class_ml

2、p('Document_0-9.omc',OCRHandle)12: do_ocr_multi_class_mlp(SelectedRegions,ImageG,OCRHandle,Class,Confidence)halcon導(dǎo)出的C#代碼:1: /2: /byHDevelopforHALCON/DOTNET(C#)Version10.03: /4: /ThisintendedtobeusedwiththeHDevelopTemplateor5: /HDevelopTemplateWPFprojectslocatedunder%HALCONEXAMPLES%c#6:7:8:9

3、:1011121314151617181920212223242526272829303132333435363738usingSystem;usingHalconDotNet;publicpartialclassHDevelopExportpublicHTuplehv_ExpDefaultWinHandle;/Mainprocedureprivatevoidaction()/LocaliconicvariablesHObjectho_Image,ho_ImageR,ho_ImageG,ho_ImageB;HObjectho_Regions,ho_Connection,ho_SelectedR

4、egions;/LocalcontrolvariablesHTuplehv_OCRHandle,hv_Class,hv_Confidence;/InitializelocalandoutputiconicvariablesHOperatorSet.GenEmptyObj(outho_Image);HOperatorSet.GenEmptyObj(HOperatorSet.GenEmptyObj(HOperatorSet.GenEmptyObj(HOperatorSet.GenEmptyObj(HOperatorSet.GenEmptyObj(HOperatorSet.GenEmptyObj(o

5、ut ho_ImageR);out ho_ImageG);out ho_ImageB);out ho_Regions);out ho_Connection);out ho_SelectedRegions);/讀取圖片ho_Image.Dispose();39: HOperatorSet.ReadImage(outho_Image,"D:/My數(shù)字識(shí)別/l.jpg");40:41: /圖像處理42: ho_ImageR.Dispose();43: ho_ImageG.Dispose();44: ho_ImageB.Dispose();45: HOperatorSet.Deco

6、mpose3(ho_Image,outho_ImageR,outho_ImageG,outho_ImageB46: );47: ho_Regions.Dispose();48: HOperatorSet.Threshold(ho_ImageG,outho_Regions,0,183);49: ho_Connection.Dispose();50: HOperatorSet.Connection(ho_Regions,outho_Connection);51:52: ho_SelectedRegions.Dispose();53: HOperatorSet.SelectShape(ho_Conn

7、ection,outho_SelectedRegions,"area","and",54: 1987.72,7500);55:56: HOperatorSet.ReadOcrClassMlp("Document_0-9.omc",outhv_OCRHandle);57: HOperatorSet.DoOcrMultiClassMlp(ho_SelectedRegions,ho_ImageG,hv_OCRHandle,58: outhv_Class,outhv_Confidence);59:60: ho_Image.Dispose();

8、61: ho_ImageR.Dispose();62: ho_ImageG.Dispose();63: ho_ImageB.Dispose();64: ho_Regions.Dispose();65: ho_Connection.Dispose();66: ho_SelectedRegions.Dispose();67:68: 69:70: publicvoidInitHalcon()71: 72: /DefaultsettingsusedinHDevelop73: HOperatorSet.SetSystem("do_low_error","false"

9、;);74: 一一75:76: publicvoidRunHalcon(HTupleWindow)77: 78: hv_ExpDefaultWinHandle=Window;79: action();80: 81:82: 83:C#工程:1: usingSystem;2: usingSystem.Collections.Generic;3: usingSystem.ComponentModel;4: usingSystem.Data;5: usingSystem.Drawing;6: usingSystem.Linq;7: usingSystem.Text;8: usingSystem.Win

10、dows.Forms;9:10: usingHalconDotNet;11:12:13: namespaceNumericalRecognition14: 15: publicpartialclassFormMain:Form16: 17: 增加代碼:18: HDevelopExportHD=newHDevelopExport();19: stringImagePath;20:21: publicFormMain()22: 23: InitializeComponent();24: btnRecognitionNumber.Enabled=false;25: 26:27: privatevoi

11、dbtnOpenImage_Click(objectsender,EventArgse)28: 29: open=JPEG文件|*jpg*|BMP文件|*bmp*|TIFF文件|*.tiff*"30:31: open=true;32:33: open=1;34:35: if(open()=DialogResult.OK)36:37: 38:39: ImagePath=open;40:41: HD.ReadImage(hWindowControl1.HalconWindow,ImagePath);42:43: btnRecognitionNumber.Enabled=true;44:4

12、5: 46: 47:48: privatevoidbtnRecognitionNumber_Click(objectsender,EventArgse)49: 50: HD.NumberRecognition();51: labNumber.Text=HD.hv_Class.ToString();52:53: btnRecognitionNumber.Enabled=false;54: 55: 56:57: /halcon導(dǎo)出的類(lèi)58: publicpartialclassHDevelopExport59: 60: publicHTuplehv_ExpDefaultWinHandle;61:6

13、2: HObjectho_Image,ho_ImageR,ho_ImageG,ho_ImageB;63: HObjectho_Regions,ho_Connection,ho_SelectedRegions;64:65:66: /Localcontrolvariables67: HTuplehv_OCRHandle,hv_Confidence;68: publicHTuplehv_Class;69:70: publicvoidInitHalcon()71: 72: /DefaultsettingsusedinHDevelop73: HOperatorSet.SetSystem("do

14、_low_error","false");74: 75:76: publicvoidReadImage(HTupleWindow,stringImagePath)77:78: hv_ExpDefaultWinHandle=Window;79:80: /Initializelocalandoutputiconicvariables81: HOperatorSet.GenEmptyObj(outho_Image);82:83: /讀取圖片84: ho_Image.Dispose();85: HOperatorSet.ReadImage(outho_Image,Imag

15、ePath);86: HOperatorSet.DispObj(ho_Image,hv_ExpDefaultWinHandle);87: 88:89:publicvoidNumberRecognition()90:91:HOperatorSet.GenEmptyObj(outho_ImageR);92:HOperatorSet.GenEmptyObj(outho_ImageG);93:HOperatorSet.GenEmptyObj(outho_ImageB);94:HOperatorSet.GenEmptyObj(outho_Regions);95:HOperatorSet.GenEmpty

16、Obj(outho_Connection);96:HOperatorSet.GenEmptyObj(outho_SelectedRegions);97:/圖像處理98:ho_ImageR.Dispose();99:ho_ImageG.Dispose();100:ho_ImageB.Dispose();101:HOperatorSet.Decompose3(ho_Image,outho_ImageR,outho_ImageG,outho_ImageB102:);103:ho_Regions.Dispose();104:HOperatorSet.Threshold(ho_ImageG,outho_

17、Regions,0,183);105:ho_Connection.Dispose();106:HOperatorSet.Connection(ho_Regions,outho_Connection);107:108:ho_SelectedRegions.Dispose();109:HOperatorSet.SelectShape(ho_Connection,outho_SelectedRegions,"area","and110:111:112:outhvOC1987.72,7500);HOperatorSet.ReadOcrClassMlp("Document_0-9.omc",:RHandle);113: HOperatorSet.DoOcrMultiClassMlp(ho_SelectedRegions,ho_ImageG

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論