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.算子如下
功能:使用带通滤波器提取边缘。
功能:检测色线和它们的宽度。
功能:使用面模型检测线。
功能:检测线和它们的宽度。
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 ()
*