* Image Acquisition 01: Code generated by Image Acquisition 01
read_image (Image, 'C:/Users/caida/Desktop/halcon计划/halcon计划/测量/_1.png')
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
set_display_font (WindowHandle, 16, 'mono', 'true', 'false')
dev_set_draw ('margin')
dev_display (Image)
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
*循环分割
for i := 1 to 3 by 1
read_image (Image1, 'C:/Users/caida/Desktop/halcon计划/halcon计划/测量/_'+i+'.png')
fast_threshold (Image1, Region, 128, 255, 20)
dev_set_draw ('margin')
edges_sub_pix (Image1, Edges, 'canny', 1, 20, 40)
segment_contours_xld (Edges, ContoursSplit, 'lines', 5, 4, 2)
count_obj (ContoursSplit, Number)
for j := 1 to Number by 1
select_obj (ContoursSplit, ObjectSelected, j)
length_xld (ObjectSelected, Length)
fit_line_contour_xld (ObjectSelected, 'tukey', -1, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
gen_contour_polygon_xld (line, [RowBegin,RowEnd], [ColBegin,ColEnd])
distance_pp (RowBegin, ColBegin, RowEnd, ColEnd, Distance)
disp_message (WindowHandle, 'L'+j, 'image', (RowBegin+RowEnd)/2, (ColBegin+ColEnd)/2, 'yellow', 'false')
disp_message (WindowHandle, 'Length: '+Length, 'window', 20*j, 12, 'green', 'false')
disp_continue_message (WindowHandle, 'black', 'true')
stop ()
endfor
stop ()
endfor
Halcon——测量边长
最新推荐文章于 2024-08-09 00:42:46 发布