调用halcon实现三点绘制圆
By
admin
at 2019-05-11 • 0人收藏 • 2556人看过
import win.ui; /*DSG{{*/ var winform = win.form(text="aardio调用halcon实现三点绘制圆 由Aardio.com.cn提供";right=735;bottom=604) winform.add( button={cls="button";text='\uF040 开始绘制';left=0;top=494;right=736;bottom=562;flat=1;font=LOGFONT(h=-21;name='FontAwesome');z=2}; edit={cls="edit";text="提示:点击[开始绘制],根据提示一步步操作";left=0;top=561;right=736;bottom=605;align="center";bgcolor=15780518;border=1;color=8421376;font=LOGFONT(h=-29);multiline=1;z=3}; picturebox={cls="picturebox";left=0;top=0;right=736;bottom=496;bgcolor=8421376;z=1} ) /*}}*/ HOperatorSetX = com.CreateObject("{6ebd90e2-d219-11d2-ade5-0000c00f4ef9}") var WindowHandle = HOperatorSetX.OpenWindow( 0 , 0 , winform.picturebox.width , winform.picturebox.width , winform.picturebox.hwnd , "transparent", "" ); winform.button.oncommand = function(id,event){ //dev_clear_window() HOperatorSetX.SetSystem( 'clip_region','false' ); //dev_set_draw('margin') HOperatorSetX.SetDraw( WindowHandle , "margin" ); HOperatorSetX.SetColor( WindowHandle , "red" ); //*下面绘制第一个点 winform.edit.text = "提示:鼠标左键点击生成第一个点,右键确认位置" var Row1, Column1 = HOperatorSetX.DrawPoint( WindowHandle ); var Cross = HOperatorSetX.GenCrossContourXld( Row1, Column1, 9, 0.785398 ); HOperatorSetX.DispObj( Cross , WindowHandle ); //*下面绘制第二个点 winform.edit.text = "提示:鼠标左键点击生成第二个点,右键确认位置" var Row2, Column2 = HOperatorSetX.DrawPoint( WindowHandle ); var Cross1 = HOperatorSetX.GenCrossContourXld( Row2, Column2, 9, 0.785398 ); HOperatorSetX.DispObj( Cross1 , WindowHandle ); //*下面绘制第三个点 winform.edit.text = "提示:鼠标左键点击生成第三个点,右键确认位置" var Row3, Column3 = HOperatorSetX.DrawPoint( WindowHandle ); var Cross2 = HOperatorSetX.GenCrossContourXld( Row3, Column3, 9, 0.785398 ); HOperatorSetX.DispObj( Cross2 , WindowHandle ); //*下面以三个点生成多边形XLD winform.edit.text = "提示:已生成外接圆" var Region = HOperatorSetX.GenContourPolygonXld( {Row1;Row2;Row3},{Column1;Column2;Column3} ); //*下面拟合圆 var Row, Column, Radius, StartPhi, EndPhi, PointOrder = HOperatorSetX.FitCircleContourXld( Region, 'algebraic', -1, 0, 0, 3, 2 ); var ContCircle = HOperatorSetX.GenCircleContourXld( Row, Column, Radius, 0, 6.28318, 'positive', 1 ); HOperatorSetX.DispObj( ContCircle , WindowHandle ); } winform.show(); win.loopMessage(); return winform;
该代码由 http://www.ihalcon.com/read-12274.html
转化而来. 感谢网友分享
登录后方可回帖