1. Halcon's most commonly used straight line detection operator, add_metrology_object_line_measure, uses the Halcon packaged model to detect not only straight lines, but also circles, ellipses, rectangles, etc. The rest of the linear detection operators are introduced below, which need to cooperate with
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) and other operators fit straight
lines
.
2. The operator is as follows
- bandpass_image
Function: Extract edges using a bandpass filter.
- lines_color
Function: Detect color lines and their width.
- lines_facet
Function: Use surface model to detect lines.
- lines_gauss
Function: Detect lines and their width.
3. Case explanation
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)
original image
bandpass_image result image
fitting straight line
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)
原图
Result Figure
3.3 lines_facet
read_image (Bk45, 'bk45')
dev_set_colored (6)
lines_facet (Bk45, Lines, 5, 3, 5, 'light')
original image
result Figure
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’)
original image
result graph