思路仅供参考,除了那个近似圆形的误别有点问题,其它的都能正确识别
- read_image (Image205146eayten6lo17nzo7a, 'C:/Users/Administrator/Desktop/205146eayten6lo17nzo7a.jpg')
- threshold (Image205146eayten6lo17nzo7a, Region, 160, 255)
- connection (Region, ConnectedRegions)
- select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 800, 1500)
- dilation_circle (SelectedRegions, RegionDilation, 3.5)
- union1 (RegionDilation, RegionUnion)
- reduce_domain (Image205146eayten6lo17nzo7a, RegionUnion, ImageReduced)
- edges_color_sub_pix (ImageReduced, Edges, 'canny', 1, 20, 40)
- select_contours_xld (Edges, SelectedContours, 'contour_length', 50, 20000, -0.5, 0.5)
- area_center_xld (SelectedContours, Area1, Row2, Column2, PointOrder)
- gen_cross_contour_xld (Cross1, Row2, Column2, 26, 0.785398)
- shape_trans_xld (SelectedContours, XLDTrans, 'rectangle2')
- count_obj (XLDTrans, Number)
- gen_empty_obj (EmptyObject)
- for Index := 1 to Number by 1
- select_obj (SelectedContours, ObjectSelected, Index)
- select_obj (XLDTrans, ObjectSelected1, Index)
- gen_region_contour_xld (ObjectSelected, Region1, 'filled')
- smallest_rectangle2_xld (ObjectSelected1, Row, Column, Phi, Length1, Length2)
- gen_rectangle2_contour_xld (Rectangle, Row, Column, Phi, Length1-0.01, Length2+3)
- intersection_contours_xld (ObjectSelected, Rectangle, 'all', Row, Column, IsOverlapping)
- gen_region_points (Region3, Row, Column)
- connection (Region3, ConnectedRegions2)
- area_center (ConnectedRegions2, Area2, Row3, Column3)
- gen_cross_contour_xld (Cross, Row3, Column3, 36, 0.785398)
- gen_circle (Circle, Row3, Column3, [10.5,10.5])
- intersection (Circle, Region1, RegionIntersection)
- area_center (RegionIntersection, Area, Row1, Column1)
- tuple_find (Area, min(Area), Indices)
- gen_cross_contour_xld (Cross2, Row3[Indices], Column3[Indices], 26, Phi)
- * dev_display (Image205146eayten6lo17nzo7a)
- * dev_display (Cross2)
- concat_obj (EmptyObject, Cross2, EmptyObject)
- * stop ()
- endfor
- dev_display (Image205146eayten6lo17nzo7a)
- dev_display (EmptyObject)
复制代码
|