是的,我使用的时edge_sub_fix来找边缘,做到很好也是找到四条线的轮廓点,然后对共线的轮廓点做并线处理,对四条线的轮廓点进行排序,对其进行距离计算,但是在排序时有时和自己想要的顺序不一样,就导致最后结果不准确,有时候准有时候不准。
- edges_sub_pix (ImageReduced, Edges, 'sobel', 1, 5, 20)
- segment_contours_xld (Edges, ContoursSplit, 'lines', 5, 4, 2)
- select_contours_xld (ContoursSplit, SelectedContours, 'contour_length', 20, 99999, -0.5, 0.5)
- union_collinear_contours_xld (SelectedContours, UnionContours, 200, 1, 200, 0.7, 'attr_keep')
- count_obj (UnionContours, Number)
- sort_contours_xld (UnionContours, SortedContours, 'upper_left', 'true', 'row')
- select_obj (SortedContours, ContourLine1, 1)
- select_obj (SortedContours, ContourLine2, 2)
- select_obj (SortedContours, ContourLine3, 3)
- select_obj (SortedContours, ContourLine4, 4)
- fit_line_contour_xld (ContourLine1, 'tukey', -1, 0, 5, 2, RowBegin1, ColBegin1, RowEnd1, ColEnd1, Nr, Nc, Dist)
- gen_contour_polygon_xld (line1, [RowBegin1, RowEnd1],[ColBegin1, ColEnd1])
- fit_line_contour_xld (ContourLine2, 'tukey', -1, 0, 5, 2, RowBegin2, ColBegin2, RowEnd2, ColEnd2, Nr, Nc, Dist)
- gen_contour_polygon_xld (line2, [RowBegin2, RowEnd2],[ColBegin2, ColEnd2])
- fit_line_contour_xld (ContourLine3, 'tukey', -1, 0, 5, 2, RowBegin3, ColBegin3, RowEnd3, ColEnd3, Nr, Nc, Dist)
- gen_contour_polygon_xld (line3, [RowBegin3, RowEnd3],[ColBegin3, ColEnd3])
- fit_line_contour_xld (ContourLine4, 'tukey', -1, 0, 5, 2, RowBegin4, ColBegin4, RowEnd4, ColEnd4, Nr, Nc, Dist)
- gen_contour_polygon_xld (line4, [RowBegin4, RowEnd4],[ColBegin4, ColEnd4])
- distance_contours_xld (ContourLine2, ContourLine3, ContourOut1, 'point_to_segment')
- get_contour_attrib_xld (ContourOut1, 'distance', Distance1)
- distance_contours_xld (ContourLine1, ContourLine4, ContourOut2, 'point_to_segment')
- get_contour_attrib_xld (ContourOut2, 'distance', Distance2)
- D1:=mean(Distance1)
- D2:=mean(Distance2)
复制代码 |