欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 人工智能 > ChatGpt >内容正文

ChatGpt

2021-03-08 Halcon初学者知识 【20】如何实现矩形拟合

发布时间:2025/3/21 ChatGpt 54 豆豆
生活随笔 收集整理的这篇文章主要介绍了 2021-03-08 Halcon初学者知识 【20】如何实现矩形拟合 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

如何将图中模糊的矩形给拟合出来?当然,第一步首先是从暗区提取亮区,然后要咋样做才能实现呢?

本文给出参考代码供大家日后慢慢分析。

read_image (Image, 'cin01') threshold(Image, Region, 128, 255) opening_rectangle1 (Region, RegionOpening, 9, 9) connection (RegionOpening, ConnectedRegions) fill_up (ConnectedRegions, RegionFillUp) select_shape (RegionFillUp, SelectedRegions, ['rectangularity','area'], 'and', [0.8,700], [1,99999]) smallest_rectangle2 (SelectedRegions, Row, Column, Phi, Length1, Length2) gen_rectangle2 (Rectangle, Row, Column, Phi, Length1, Length2) boundary (Rectangle, RegionBorder, 'inner_filled') dilation_rectangle1 (RegionBorder, RegionDilation, 4, 4) reduce_domain (Image, RegionDilation, ImageReduced) edges_sub_pix (ImageReduced, Edges, 'canny', 1.5, 30, 40) segment_contours_xld (Edges, ContoursSplit, 'lines', 5, 2, 2) select_contours_xld (ContoursSplit, SelectedContours1, 'contour_length', 10, 99999, -0.5, 0.5) union_adjacent_contours_xld (SelectedContours1, UnionContours1, 100, 1, 'attr_keep') fit_rectangle2_contour_xld (UnionContours1, 'tukey', -1, 0, 0, 3, 2, Row1, Column1, Phi1, Length11, Length12, PointOrder1) gen_rectangle2_contour_xld (Rectangle1, Row1, Column1, Phi1, Length11, Length12)

 

总结

以上是生活随笔为你收集整理的2021-03-08 Halcon初学者知识 【20】如何实现矩形拟合的全部内容,希望文章能够帮你解决所遇到的问题。

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