HALCON从入门到入门-点到圆的距离计算

测试效果

处理步骤

读取图片,获取图片宽度高度

read_image (Rim, 'rim')

get_image_size (Rim, Width, Height)

通过图像计算出XLD轮廓,通过条件筛选出对应的XLD

edges_sub_pix (Rim, Edges, 'canny', 4, 20, 40)

select_shape_xld (Edges, Holes, 'circularity', 'and', 0.7, 1.0)

sort_contours_xld (Holes, Holes, 'upper_left', 'true', 'row')

获取这个轮廓的最小外接圆参数

smallest_circle_xld (Holes, Row, Column, Radius)

count_obj (Holes, Number)

循环每个圆形XLD,计算最小外接圆的中心到这个轮廓的最小最大距离(通过这两个参数来判定这个圆形是否标准还是说有形变)

for i := 1 to Number by 1

select_obj (Holes, Hole, i)

dev_display (Rim)

dev_display (Hole)

distance_pc (Hole, Row[i - 1], Column[i - 1], DistanceMin, DistanceMax)

disp_cross (WindowID, Row[i - 1], Column[i - 1], 6, 0)

测试代码

* Example program for distance_pc
* Determine the minimal and maximal radius of drill holes
* 
dev_close_window ()
read_image (Rim, 'rim')
get_image_size (Rim, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowID)
dev_display (Rim)
set_display_font (WindowID, 14, 'mono', 'false', 'false')
* Segment the circular holes
* The alpha parameter was choosen different than the default value
* to ensure stronger smoothing and thusmore connected edge components
edges_sub_pix (Rim, Edges, 'canny', 4, 20, 40)
select_shape_xld (Edges, Holes, 'circularity', 'and', 0.7, 1.0)
sort_contours_xld (Holes, Holes, 'upper_left', 'true', 'row')
* Determine the midpoints
smallest_circle_xld (Holes, Row, Column, Radius)
count_obj (Holes, Number)
dev_set_color ('yellow')
* For all boles ...
for i := 1 to Number by 1
    select_obj (Holes, Hole, i)
    dev_display (Rim)
    dev_display (Hole)
    * Compute the minimal and maximal radius of the holes by computing the
    * distance of the midpoint to the contour
    distance_pc (Hole, Row[i - 1], Column[i - 1], DistanceMin, DistanceMax)
    * And visualize the results (minimal and maximal radius)
    disp_cross (WindowID, Row[i - 1], Column[i - 1], 6, 0)
    tuple_string (DistanceMin, '.3f', SVal)
    get_string_extents (WindowID, 'min: ' + SVal, Ascent, Descent, Width1, Height1)
    disp_message (WindowID, 'min: ' + SVal, 'image', Row[i - 1] - 2 * Ascent, Column[i - 1] - Radius[i - 1] - Width1 - 10, 'black', 'true')
    disp_message (WindowID, 'max: ' + DistanceMax$'.3f', 'image', Row[i - 1], Column[i - 1] - Radius[i - 1] - Width1 - 10, 'black', 'true')
    disp_continue_message (WindowID, 'black', 'true')
    stop ()
endfor
dev_close_window ()

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
"Halcon入门到精通.pdf" 是一本关于Halcon 软件的学习资料,在网络上我们可以通过网盘来分享和下载这本书。 网盘是一种在线存储和分享文件的工具。通过网盘,用户可以将文件上传到服务器上,然后生成一个文件链接。其他用户则可以通过该链接下载文件。与传统的文件传输方式相比,网盘具有上传下载快速、方便、安全的特点。 对于"Halcon入门到精通.pdf"这样的学习资料,使用网盘来分享是非常合适的。首先,这样可以让更多的人获得学习机会,无论是学习软件的初学者还是想进一步提高的专业人士。其次,通过网盘分享,可以避免传统的文件复制和邮件发送过程中的版本混淆和文件丢失问题。最后,网络上的网盘资源丰富,用户可以通过搜索引擎或文件分享网站找到自己所需的学习资料。 使用网盘下载"Halcon入门到精通.pdf"时,建议大家首先确保所使用的网盘链接来源可靠。在下载之前最好对文件进行一定的检查,以确保文件的完整性和安全性。此外,强烈建议大家在下载和使用学习资料的过程中遵守相关的法律和规定,不要进行非法的复制和传播行为。 总而言之,网盘是一个方便快捷的文件分享和下载工具。对于"Halcon入门到精通.pdf"这样的学习资料,使用网盘来分享和获取是非常适合的。希望这份回答能对您有所帮助。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黄晓魚

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值