欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

halcon通过点拟合圆形,鼠标选点

发布时间:2023/12/10 编程问答 34 豆豆
生活随笔 收集整理的这篇文章主要介绍了 halcon通过点拟合圆形,鼠标选点 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

原图

源码

read_image (Image, '0.bmp') dev_clear_window () dev_open_window_fit_image (Image, 0, 0, -1, -1, WindowHandle) dev_display (Image)binary_threshold (Image, Region, 'max_separability', 'dark', UsedThreshold) connection (Region, ConnectedRegions) select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 100, 100000)gen_empty_obj (CircleRegion) PointNumber:=0 while (PointNumber<8)draw_point (WindowHandle, Row, Column)gen_region_points (Region1, Row, Column)select_shape_proto (SelectedRegions, Region1, SelectedRegions1, 'overlaps_abs', 1, 5)count_obj (SelectedRegions1, Number)if(Number>0)concat_obj (CircleRegion, SelectedRegions1, CircleRegion)PointNumber:=PointNumber+1endif endwhilesmallest_circle (CircleRegion, Row1, Column1, Radius)pts_to_best_circle (Circle, Row1, Column1, RowCenter, ColCenter, Radius)dev_display (Image)dev_display (Circle)

pts_to_best_circle 函数

RowCenter := 0 ColCenter := 0 Radius := 0gen_empty_obj (Circle) tuple_length(Cols, Length)if (Length>2)gen_contour_polygon_xld(Contour, Rows, Cols)fit_circle_contour_xld (Contour, 'geotukey', -1, 0, 0, 3, 2, RowCenter, ColCenter, Radius, StartPhi, EndPhi, PointOrder)tuple_length(StartPhi, Length1)if(Length1<1)return()endifgen_circle_contour_xld(Circle, RowCenter, ColCenter, Radius, StartPhi, EndPhi, PointOrder, 1)endif return ()

处理结果

总结

以上是生活随笔为你收集整理的halcon通过点拟合圆形,鼠标选点的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。