資源描述:
《基于halcon的研究》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、vc使用halcon使用hdevelop導(dǎo)出halcon程序的C++代碼之后,比如rcad_image(image,'C:/DocumentsandSettings/Administreitor/桌面/vision/IMG_20121015_091436.bmp,)2rgbltogray(image,GrayImage)3dev_set_color(,blue')4*bin_threshold(GrayImage,Region)5threshold(Grayimage,Rcgion,100,255)6a
2、rea_center(Region,Area,Row,Column)牛?成C++代碼0///////////////////////////////////////////////////////////////////1////////////02//FilegeneratedbyUDevelopfor1IALC0N/C++Vcrsion10.00///////////////////////////////////////////////////////////////////3//////////
3、//04050607Sincludez,HalconCpp.h〃08091011usingnamcspaccIlalcon;1213ldttifndefN0_EXP0RT_MAIN15//Mainprocedure16voidaction()17{18usingnamespaceHalcon;1920//Localiconicvariables21Ilobjcctimage,Graylmagc,Rcgion;222324//Localcontrolvariables25HTupleArea,Row,Co
4、lumn;26readimage(&image,〃C:/DocumentsandSettings/Administrator/桌7面/vision/TMG_20121015_091436.bmp");28rgbl_to_gray(image,&Graylmagc);29if(HDevWindowStack::IsOpenO)30set_co1or(HDevWindowStack::GetActive(),"blue");31binthreshold(Grayimage,&Region);28area_c
5、enter(Region,&Area,&Row,&Column);3334}353637#ifndefNO_EXPORT_APP_MAIN38intmain(intargc,char*argv[])39{40usingnamespaceHalcon;41//DefaultsettingsusedinHDevelop(canbeomitted)42set_system(/zdo_low_errorz/,z/false/z);43action();44rctuni0;45}46fiendif474847#e
6、ndif新建一個對話框mfc程序(vc2008),添加一個按鈕button1,加入如下代碼(我將action函數(shù)稍微改了一下)當(dāng)然先要#include"HalconCpp.h"01//Mai02doublenprocedureaction(char*p)03{04usingnamespaceHalcon;05//Localiconicvariables06Hobjectimage,GrayTmage,Region;0708//Localcontrolvariables091011121314151617
7、18192021}2223UTupleArea,Row,Column;read_image(&image,p);rgbltogray(image,&GrayImage);if(HDevWindowStack::IsOpen())set_color(HDevWindowStack::GetActive(),"blue");//bin_thrcshold(Graylmagc,&Rcgion);threshold(Grayimage,&Region,50,255);area_center(Region,&Ar
8、ea,&Row,&Column);doubled=Area[0];returnd;24voidCabcDlg::0nBnClickedButtonl()25{26//TODO:在此添加控件通知處理程序代碼doubled=action(/ZC:/DocumentsandSettings/Administrator/桌面/vision/IMG_20121015_091436.bmp〃);28293031}CStringstr;str.Forma