5、机器视觉之轮廓的操作

read_image (Image, 'rings_and_nuts')

threshold (Image, Region, 0, 128)

*获取轮廓
*1、通过边缘来提取轮廓"亚像素"
edges_sub_pix (Image, Edges, 'canny', 1, 20, 40)


edges_image (Image, ImaAmp, ImaDir, 'canny', 1, 'nms', 20, 40)

*2.region →轮廓
gen_contour_region_xld (Region, Contours, 'center')

* select_contours_xld (Contours, SelectedContours, 'contour_length', 0.5, 200, -0.5, 0.5)

*筛选弧度>0.9的圆弧

circularity_xld (Edges, Circularity)//轮廓或边缘的圆度
tuple_greater_elem (Circularity, 0.90, Greater)//测试一个元组是否大于另一个元组 
tuple_find (Greater, 1, Indices)//返回一个元组在另一个元组中所有出现的索引


dev_set_color ('red')
dev_set_line_width (5)
select_obj (Edges, ObjectSelected, Indices+1)//从对象元组中选择对象

*轮廓的合并
*轮廓的拟合
*1.圆或圆弧的拟合
fit_circle_contour_xld (Contours, 'algebraic', -1, 0, 0, 3, 2, Row, Column, Radius, StartPhi, EndPhi, PointOrder)

*通过点转换到轮廓
select_obj (Contours, ObjectSelected1, 2)
get_contour_xld (ObjectSelected1, Row1, Col)

tuple_select_range (Row1, 0,300, SelectedRow)
tuple_select_range (Col, 0,300, SelectedCol)


gen_contour_polygon_xld (Contour, SelectedRow, SelectedCol)
fit_circle_contour_xld (Contour, 'algebraic', -1, 0, 0, 3, 2, Row2, Column1, Radius1, StartPhi1, EndPhi1, PointOrder1)

gen_circle_contour_xld (ContCircle, Row2, Column1, Radius1, StartPhi1, StartPhi1,'negative', 1)


*轮廓的变换
smallest_rectangle1_xld (ContCircle, Row11, Column11, Row21, Column2)

gen_rectangle1 (Rectangle, Row11, Column11, Row21, Column2)


*轮廓的分割
segment_contours_xld (ContCircle, ContoursSplit, 'lines_circles', 5, 4, 2)

*轮廓的裁剪
gen_rectangle1 (Rectangle1, Row11, Column11, Row21, Column2)

clip_contours_xld (ContoursSplit, ClippedContours, Row11, Column11, Row21, Column2)
上一篇:购物车续集1


下一篇:AT2346 [ARC070B] No Need