halcon中测量圆弧尺寸 您所在的位置:网站首页 halcon拟合直线算子 halcon中测量圆弧尺寸

halcon中测量圆弧尺寸

2023-03-16 19:08| 来源: 网络整理| 查看: 265

halcon中测量圆弧尺寸

前言

主要测量一个圆弧块的尺寸,其中主要用到算子:get_points_ellipse( : : Angle, Row, Column, Phi, Radius1, Radius2 : RowPoint, ColPoint)、gen_ellipse_contour_xld( : ContEllipse : Row, Column, Phi, Radius1, Radius2, StartPhi, EndPhi, PointOrder, Resolution : )、gen_contour_polygon_xld( : Contour : Row, Col : )、disp_arc( : : WindowHandle, CenterRow, CenterCol, Angle, BeginRow, BeginCol : )、gen_measure_arc( : : CenterRow, CenterCol, Radius, AngleStart, AngleExtent, AnnulusRadius, Width, Height, Interpolation : MeasureHandle) 下面将用一个简单例子解释这几个主要算子含义以及应用

一、样例

在这里插入图片描述在这里插入图片描述

*读取图片 read_image (Zeiss1, 'zeiss1') *获取图片长宽 get_image_size (Zeiss1, Width, Height) *关闭所有窗口 dev_close_window () *打开一个新的窗口,其中宽Width / 2,高Height / 2,窗口句柄WindowHandle dev_open_window (0, 0, Width / 2, Height / 2, 'black', WindowHandle) *设定窗口字体参数 set_display_font (WindowHandle, 14, 'mono', 'true', 'false') *显示图像 dev_display (Zeiss1) *显示按键F5继续信息 disp_continue_message (WindowHandle, 'black', 'true') *暂停程序,等待按键F5输入 stop () * 准备生成椭圆的一些参数 Row := 275 Column := 335 Radius := 107 AngleStart := -rad(55) AngleExtent := rad(170) angle:=AngleExtent+AngleStart *设定填充方式 dev_set_draw ('fill') *设定字体,轮廓等颜色 dev_set_color ('green') *设定轮廓宽度 dev_set_line_width (1) *获取椭圆轮廓上面的一点,后续详细解释参数 get_points_ellipse (AngleStart + AngleExtent, Row, Column, 0, Radius, Radius, RowPoint, ColPoint) *生成一个十字轮廓,用于标记上面获取椭圆上的一点 gen_cross_contour_xld (Cross, RowPoint, ColPoint, 10, 0) *生成一个十字轮廓,用于标记上面椭圆的圆心 gen_cross_contour_xld (Cross1, Row, Column, 10, 0) row1:=[Row,RowPoint] col1:=[Column,ColPoint] *生成一个多边形,其实使用椭圆上一点和椭圆圆心连接的直线 gen_contour_polygon_xld (Contour, row1, col1) *生成一个椭圆轮廓,后面算子参数有详细解释 gen_ellipse_contour_xld (ContEllipse, Row, Column, 0, Radius, 50, rad(3), rad(360), 'positive', 1.5) *设定轮廓宽度 dev_set_line_width (3) *显示椭圆图形,详细算子参数后续解释 disp_arc (WindowHandle, Row, Column, AngleExtent, RowPoint, ColPoint) *生成一个圆弧测量工具,其测量句柄是MeasureHandle gen_measure_arc (Row, Column, Radius, AngleStart, AngleExtent, 10, Width, Height, 'nearest_neighbor', MeasureHandle) *显示按键F5继续信息 disp_continue_message (WindowHandle, 'black', 'true') *暂停程序,等待按键F5输入 stop () *计时器 count_seconds (Seconds1) n := 10 for i := 1 to n by 1 *测量边缘 measure_pos (Zeiss1, MeasureHandle, 1, 10, 'all', 'all', RowEdge, ColumnEdge, Amplitude, Distance) endfor count_seconds (Seconds2) Time := (Seconds2 - Seconds1) / n disp_continue_message (WindowHandle, 'black', 'true') * stop () * 二点之前距离 distance_pp (RowEdge[1], ColumnEdge[1], RowEdge[2], ColumnEdge[2], IntermedDist) * dev_display (Zeiss1) dev_set_color ('red') * disp_circle (WindowHandle, RowEdge, ColumnEdge, RowEdge - RowEdge + 1) * 显示直线标注 disp_line (WindowHandle, RowEdge[1], ColumnEdge[1], RowEdge[2], ColumnEdge[2]) disp_line (WindowHandle, RowEdge[0], ColumnEdge[0], RowEdge[1], ColumnEdge[1]) disp_line (WindowHandle, RowEdge[2], ColumnEdge[2], RowEdge[3], ColumnEdge[3]) dev_set_color ('yellow') *显示距离信息 disp_message (WindowHandle, 'Distance: ' + IntermedDist, 'image', 250, 80, 'yellow', 'false') * dump_window (WindowHandle, 'tiff_rgb', 'C:\\Temp\\zeiss_result') dev_set_line_width (1) * disp_continue_message (WindowHandle, 'black', 'true') stop () *清空窗口信息 dev_clear_window () 二、主要使用算子详细解释 1.get_points_ellipse( : : Angle, Row, Column, Phi, Radius1, Radius2 : RowPoint, ColPoint)

根据指定参数获取椭圆轮廓上一点,详细参数如下: 输入参数: Angle:椭圆上一点和椭圆圆心连线,这条直线和椭圆长轴的角度 Row:椭圆Row Column:椭圆Column Phi:椭圆长轴和X轴的夹角 Radius1:椭圆长轴 Radius2 :椭圆短轴

输出参数: RowPoint:椭圆上一点RowPoint ColPoint:椭圆上一点ColPoint 2.gen_measure_arc( : : CenterRow, CenterCol, Radius, AngleStart, AngleExtent, AnnulusRadius, Width, Height, Interpolation : MeasureHandle)

在这里插入图片描述



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有