0
点赞
收藏
分享

微信扫一扫

halcon知识:如何检出部分圆?

林肯公园_97cc 2022-02-05 阅读 154

一、前言

        学习Halcon的技巧,不是对语言或算子详细研究;而是对自己的目的如何实现进行研究,或者更直白的说,就是“面对自己的某个目的,需要哪些算子共同组合才能完成”。
        本篇的案例是,图像中的边缘被分割成线和圆。对于属于圆的边,估计圆参数,并显示结果圆出。

二、分析

比如在如下的途中,如何提取出圆和直线段来,并将圆弧的圆画出。

2.1 程序代码


read_image (Image, 'double_circle')
* 
* Init window
dev_close_window ()
get_image_size (Image, Width, Height)
dev_open_window (0, 0, Width, Height, 'black', WindowHandle)
* 
* Segment a region containing the edges
fast_threshold (Image, Region, 0, 120, 7)
boundary (Region, RegionBorder, 'inner')
clip_region_rel (RegionBorder, RegionClipped, 5, 5, 5, 5)
dilation_circle (RegionClipped, RegionDilation, 2.5)
reduce_domain (Image, RegionDilation, ImageReduced)
* 
* In the subdomain of the image containing the edges,
* extract subpixel precise edges.
edges_sub_pix (ImageReduced, Edges, 'canny', 2, 20, 60)
segment_contours_xld (Edges, ContoursSplit, 'lines_circles', 5, 4, 3)
count_obj (ContoursSplit, Number)
dev_display (Image)
dev_set_draw ('margin')
dev_set_color ('white')
dev_update_window ('off')
for I := 1 to Number by 1
    select_obj (ContoursSplit, ObjectSelected, I)
    get_contour_global_attrib_xld (ObjectSelected, 'cont_approx', Attrib)
    * Fit a circle to the line segment that are arcs of a circle
    if (Attrib > 0)
        fit_circle_contour_xld (ObjectSelected, 'ahuber', -1, 2, 0, 3, 2, Row, Column, Radius, StartPhi, EndPhi, PointOrder)
        gen_circle_contour_xld (ContCircle, Row, Column, Radius, 0, rad(360), 'positive', 1.0)
        dev_display (ContCircle)
    endif
endfor
dev_set_colored (12)
dev_set_line_width (3)
dev_display (ContoursSplit)

2.2 要点分析

  • 1)如何准确获取边缘
  • 2)如何获得直线,或圆的一些分段。
  • 3)如何通过弧找出大圆

2.3 代码说明

xxxxxxxxxxxxx

举报

相关推荐

0 条评论