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’)
原图

  • 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’)

原图

结果图

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
心中带点小风骚的头像心中带点小风骚普通用户
上一篇 2023年8月9日
下一篇 2023年8月9日

相关推荐

此站出售,如需请站内私信或者邮箱!