dev_update_off ()
dev_close_window ()
dev_open_window (0, 0, 978, 324, ‘black‘, WindowHandle)
dev_set_part (0, 0, 647, 1955)
set_display_font (WindowHandle, 16, ‘mono‘, ‘true‘, ‘false‘)
dev_set_color (‘yellow‘)
*检测图中有多少个圈
*dev_set_line_width (3)
read_image (Image, ‘C:/Users/Administrator/Desktop/20190727090119176.png‘)
*因为是随手用画板制的图,需要用到滤波器过滤线条
gauss_filter (Image, ImageGauss, 9)
threshold_sub_pix (ImageGauss, Border, 200)
*根据一种模型拆解轮廓线
segment_contours_xld (Border, ContoursSplit, ‘lines’, 1, 1, 1)
*使用共线链接,缝合这些满足条件的轮廓线
union_cotangential_contours_xld (ContoursSplit, UnionContours, 4, 30, rad(45), 25, 10, 2, ‘attr_forget‘)
*筛选掉没有缝合到的短的轮廓线
select_contours_xld (UnionContours, SelectedContours, ‘contour_length‘, 100, 99999, -0.5, 0.5)
count_obj (SelectedContours, Num_All)
Num:=Num_All/2
dev_clear_window ()
dev_display (Image)
set_display_font (WindowHandle, 30, ‘mono’, ‘true‘, ‘false‘)
write_string (WindowHandle, ‘检测出’+Num+’个圈圈’)
原文地址:https://blog.csdn.net/u014090257/article/details/134789739
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_41072.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!