2021-03-08 Halcon初学者知识 【20】如何实现矩形拟合
生活随笔
收集整理的這篇文章主要介紹了
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】如何实现矩形拟合的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2021-03-04 Halcon初学者
- 下一篇: 2021-03-15 深入理解SLAM