0


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

原图
在这里插入图片描述

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


本文转载自: https://blog.csdn.net/Douhaoyu/article/details/128206473
版权归原作者 豆浩宇 所有, 如有侵权,请联系我们删除。

“Halcon直线检测”的评论:

还没有评论