Halcon直线检测

1.Halcon最常用的直线检测算子,add_metrology_object_line_measure,利用Halcon封装好的模型不仅可以检测直线,还可以检测圆,椭圆,矩形等。下面介绍下其余的直线检测的算子,需要配合
skeleton (SelectedRegions, Skeleton)
gen_contours_skeleton_xld (Skeleton, Contours, 5, ‘filter’)
fit_line_contour_xld (Contours, ‘tukey’, -1, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
gen_region_line (RegionLines, RowBegin, ColBegin, RowEnd, ColEnd)
等算子拟合直线。
2.算子如下

  1. bandpass_image

功能:使用带通滤波器提取边缘。

  1. lines_color

功能:检测色线和它们的宽度。

  1. lines_facet

功能:使用面模型检测线。

  1. lines_gauss

功能:检测线和它们的宽度。
3.案例解释
3.1 bandpass_image

dev_close_window ()
dev_open_window (0, 0, 512, 512, ‘black’, WindowHandle)
dev_set_draw (‘margin’)
read_image (Image, ‘C:/Users/Dell/Desktop/2022_11_28_15_44_14_0588_id_36429.bmp’)
median_rect (Image, ImageMedian, 9, 9)
bandpass_image (ImageMedian, ImageBandpass, ‘lines’)
threshold (ImageBandpass, Regions, 21, 255)
connection (Regions, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, ‘area’, ‘and’, 536.53, 1000)
skeleton (SelectedRegions, Skeleton)
gen_contours_skeleton_xld (Skeleton, Contours, 5, ‘filter’)
fit_line_contour_xld (Contours, ‘tukey’, -1, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
gen_region_line (RegionLines, RowBegin, ColBegin, RowEnd, ColEnd)
原图
在这里插入图片描述
bandpass_image结果图
在这里插入图片描述
拟合直线
在这里插入图片描述
3.2 lines_color

read_image (Image, 'cable' + J)
dev_display (Image)
disp_message (WindowHandle, 'Color image', 'window', 12, 12, 'black', 'true')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
lines_color (Image, Lines, 3.5, 0, 12, 'true', 'false')
select_contours_xld (Lines, LongLines, 'contour_length', 450, 100000, 0, 0)
原图

在这里插入图片描述
结果图
在这里插入图片描述
3.3 lines_facet
read_image (Bk45, ‘bk45’)
dev_set_colored (6)
lines_facet (Bk45, Lines, 5, 3, 5, ‘light’)
原图
在这里插入图片描述
结果图
在这里插入图片描述
3.4 lines_gauss
dev_update_off ()
dev_close_window ()
dev_close_window ()
*

  • Read an aerial image
    read_image (Image, ‘mreut4_3’)
    dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle1)
    set_display_font (WindowHandle1, 16, ‘mono’, ‘true’, ‘false’)
    dev_display (Image)
    disp_message (WindowHandle1, ‘Extract the roads from an aerial image’, ‘window’, 12, 12, ‘black’, ‘true’)
    disp_continue_message (WindowHandle1, ‘black’, ‘true’)
    stop ()
  • Segment the image and reduce the domain
    threshold (Image, Region, 160, 255)
    reduce_domain (Image, Region, ImageReduced)
  • Detect the lines that represent the road centers
    MaxLineWidth := 5
    Contrast := 70
    calculate_lines_gauss_parameters (MaxLineWidth, Contrast, Sigma, Low, High)
    lines_gauss (ImageReduced, RoadCenters, Sigma, Low, High, ‘light’, ‘true’, ‘bar-shaped’, ‘true’)

原图
在这里插入图片描述

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

  • 1
    点赞
  • 36
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值