资源描述:
《跟我学机器视觉--example》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、HALCON学习例程中文-IC引脚测量路径-------C:ProgramFilesMVTecHALCON-10.0exampleshdevelopApplicationsMeasuring-2Dmeasure_pin.hdev·LeadMeasurement:Examplefortheapplicationofthemeasureobject·includingalotofvisualizationoperators.·First,thelengthoftheleadsismeasured,then,theirwidthanddistancefr
2、omeachother.·First,readintheimageandinitializetheprogramRead_image(Image,'icpin')****取得图像第一通道的指针,同时得到图像宽度高度**Get_image_pointer1(Image,Pointer,Type,Width,Height)*get_image_pointer1(Image:::Pointer,Type,Width,Height);获得图像的数据。如:类型(='字节',''',uint2int2等等)和图像的尺寸(的宽度和高度)Dev_close_window()dev
3、_close_window(:::) 关闭活跃的图形窗口。Dev_open_window_fit_image(Image,0,0,509,509,WindowHandle)设置窗口自适应图片,获得句柄Set_display_font(WindowHandle,14,'mono','true','false')内部程序,设置字体dev_display(Image)****显示图像如下:************·DefineanddisplaytherectangularROIswithinwhichtheedgeswillbedetected//ROI设置Dev_
4、set_draw('margin')Dev_se_tline_width(3)Row:=55RowBottom:=955Column:=200Phi:=rad(-90)Length1:=50Length2:=35devsetcolor('gray')gen_rectangle2(Rectangle,Row,Column,Phi,Length1,Length2)gen_rectangle2(Rectangle,RowBottom,Column,Phi,Length1,Length2)创建ROI的矩形显示区域*******测量位置如绿色矩形所示下:********Di
5、sp_continue_message(WindowHandle,'black','true')显示‘继续’信息stop()·CreateameasureobjectfortheROIatthetopoftheimage.*获取一阶灰度剖面图的插值方法,测量矩形框与图像坐标系之间有角度时生效*Interpolation:='nearest_neighbor'********生成测量矩形框,先测上部********Gen_measure_rectangle2(Row,Column,Phi,Length1,Length2,Width,Height,Interpolat
6、ion,MeasureHandle)·Determinealledgesandcalculatetheleadheightatthetopoftheimage//垂直与矩形的直线边缘的提取。Sigma:=1.0Threshold:=30Transition:='all'Select:='all'***********进行测量*********measure_pos(Image,MeasureHandle,Sigma,Threshold,Transition,Select,RowEdge,ColumnEdge,Amplitude,Distance)提取与矩形或环状弧
7、垂直的直线边缘。LeadLength1:=Distance·Displaytheresultsdevsetcolor('white')**********将测量结果画出********disp_line(WindowHandle,RowEdge,ColumnEdge-Length2,RowEdge,ColumnEdge+Length2)disp_message(WindowHandle,'LeadLength:'+LeadLength1$'.2f','window',RowEdge[1]+40,ColumnEdge[1]+100,'yellow','false')
8、程序写入文