read_image (Image, ‘D:/Project/PC_视觉类/视库/样图/二维测量例子2.png‘)
threshold_sub_pix (Image, Border, 128)
dev_get_window (WindowHandle)
segment_contours_xld (Border, ContoursSplit, ‘lines_circles‘, 5, 4, 2)
count_obj (ContoursSplit, Number)
for Index := 1 to Number by 1
select_obj (ContoursSplit, ObjectSelected, Index)
get_contour_global_attrib_xld (ObjectSelected, ‘cont_approx‘, Attrib) //注意:自动带出来的好像不是cont_approx
dev_clear_window ()
if(Attrib == -1)
fit_line_contour_xld (ObjectSelected, ‘tukey‘, -1, 0, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
disp_line (WindowHandle, RowBegin, ColBegin, RowEnd, ColEnd)
endif
if(Attrib ==1)
fit_circle_contour_xld (ObjectSelected, ‘algebraic‘, -1, 0, 0, 3, 2, Row, Column, Radius, StartPhi, EndPhi, PointOrder)
gen_circle (Circle, Row, Column, Radius)
endif
stop ()
endfor
原文:https://www.cnblogs.com/dingyd/p/13031137.html