资源描述:
《跟我学机器视觉-HALCON学习例程中文详解-开关引脚测量》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、跟我学机器视觉-HALCON学习例程中文详解■开关引脚测量*Thisexampleprogramdemonstratesthebasicusageofameasureobjec匸*Here,thetaskistodeterminethewidthofandthedistancebetweenthe*pinsofaswitch.*本例程演示了如何使用测量工具测量开关的引脚宽度和间距*First,readintheimageandinitializetheprogram.打开图像read_image(Im
2、age,,bin_switch/bin_switch_lf)get」mage_size(Image,Width,Height)dev_close_window()dev_open_window_fit_image(Image,0,0,640,640,WindowHandle)set_display_font(WindowHandle,14,'mono;true;'false')dev_display(Image)*显示图片如下*DefinetherectangularROIwithinwhichthe
3、edgeswillbedetected*andcreatethemeasure・Row:=390Column:=380Phi:=rad(-60)Length1:=60Length2:=10Inteipolation:=^earescneighbor1*************************生成测量矩形RO[**************************************gen_measure_rectangle2(Row,Column,Phi,LengthI,Length!,Wi
4、dth,Height,Interpolation,MeasureHandle)窃测量矩形位置尺寸如下:Determinealledgepairsthathaveanegativetransition,i.e.,edgepairs*thatenclosedarkregions.Sigma:=0.9Threshold:=12Transition:='negativeVisualizetheresultsdev_display(Image)dev_set_draw('margin')Select:='all
5、'6、
7、111I■.I•了.;,卜rYw»TwrYwrYwrYwrTw»T>rYwt
8、lIII'
9、*
10、*1JIff、IrYwrTw»T>rYw11、ev_set_color(/black1)■匕<1*•匕*1*•匕*1*■匕・b•匕■匕■立■匕■匕■立叫・叫・哼・彳・彳・彳・*T**T**T*彳・彳・彳・*T**T*gen_rectangle2(Rectangle,Row,Column,Phi,Length1,Length2)显示测量的边缘对的尺寸jengthl要用ROI的宽度*****************************p_disp_dimensions(RowEdgeFirst,ColumnEdgeFirst,RowEdgeSec
12、ond,ColumnEdgeSecond,IntraDistance,InterDistance,Phi,Length2,WindowHandle)*结果如下:4z严环八j显示测量矩形ROImeasure_pairs(Image,MeasureHandle,Sigma,Threshold,Transition,Select,RowEdgeFirst,ColumnEdgeFirst,AmplitudeFirst,RowEdgeSecond,ColumnEdgeSecond,AmplitudeSecond
13、,IntraDistance,InterDistance)11*Freethememorythathasbeenallocatedforthemeasure.close_measure(MeasureHandle)