如图,测量红框中的角度,代码如下:
*读取并截取图片
dev_close_window()
read_image (Image, 'C://Users//Administrator//Desktop//1测试图.jpg')
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
dev_display (Image)
*获取图形的边界
draw_rectangle1 (WindowHandle, Row1, Column1, Row2, Column2)
gen_rectangle1 (Rectangle, Row1, Column1, Row2, Column2)
reduce_domain (Image, Rectangle, ImageReduced)
threshold (ImageReduced, Regions, 80, 255)
*threshold (ImageReduced, Regions, 0, 112)
*获取三角形各边的信息
skeleton(Regions,TriangleSkeleton)
gen_contours_skeleton_xld(TriangleSkeleton,TriangleContours,1,'filter')
segment_contours_xld(TriangleContours,ContoursSplit,'lines_circles', 5, 4, 2)
select_contours_xld(ContoursSplit,SelectedContours, 'contour_length',20, 999, -0.5, 0.5)
fit_line_contour_xld (SelectedContours, 'tukey', -1, 10, 5, 2, RowBegin, ColBegin, RowEnd, ColEnd, Nr, Nc, Dist)
*计算三角形角度
angle_ll (RowBegin[0], ColBegin[0], RowEnd[1], ColEnd[1], RowBegin[0], ColBegin[0], RowEnd[2], ColEnd[2], Angle1)
Angle1:=abs(deg(Angle1))
参考:https://www.cnblogs.com/hanzhaoxin/archive/2013/02/12/2910338.html