halcon边缘查找和后续处理

By admin at 2018-02-03 • 0人收藏 • 3121人看过
disp_arrow (WindowID, Row, Column, Row2, Column2, 2)

在屏幕上显示一个箭头

如果下面紧接着是

write_string (WindowID, i)

那个这个字符串的位置就是在箭头所指位置.....

5 个回复 | 最后更新于 2018-02-03
2018-02-03   #1
edges_sub_pix (ImageReduced, Edges, 'canny', 1.5, 10, 40)
segment_contours_xld (Edges, ContoursSplit, 'lines_circles', 5, 2, 2)
select_contours_xld (ContoursSplit, SelectedContours, 'contour_length', 25, 99999, -0.5, 0.5)

segment_contours_xld——Segment XLD contours into line segments and circular or elliptic arcs(将一个XLD轮廓分割为直线段、圆(圆弧)、椭圆弧。)

查看边缘

分解边缘为line和circle属性

选择分解后的长度在xxx范围内的..

count_obj (SelectedContours, NumberContours)
gen_empty_obj (Circles)
for i := 1 to NumberContours by 1
    select_obj (SelectedContours, ObjectSelected, i)
    get_contour_global_attrib_xld (ObjectSelected, 'cont_approx', Attrib)
    if (Attrib == 1)
        concat_obj (Circles, ObjectSelected, Circles)
    endif
endfor

计数

选择分解后的线或者圆属性体

获取选择的属性特征,如果是

Remark:

分割得到的轮廓是直线段、圆(圆弧)或者椭圆弧可以通过分割后轮廓的全局属性'cont_approx’参数的值来确定(参考get_contour_global_attrib_xld)。

如果'cont_approx'=-1,这一部分轮廓最适合被拟合为直线段。

如果'cont_approx'=0,这一部分轮廓最适合被拟合为椭圆弧。

如果'cont_approx'=1,这一部分轮廓最适合被拟合为圆弧。


2018-02-03   #2

对于圆形区域,我们想拟合出它的圆形轮廓或者其他的圆,我们可以用如下的方法拟合出来:

(1)、如果该区域是一个圆环区域的话,那就运行骨架算子skeleton得到圆环区域的骨架,然后用gen_contours_skeleton_xld生成骨架轮廓。如果该区域是圆形区域,那么可以用产生区域轮廓算子gen_contour_region_xld()产生圆形轮廓。

(2)、有了轮廓后可以先用segment_contours_xld分割一下轮廓。

(3)、对于上一步分割后的轮廓采取一些选择措施,选择出满意的轮廓,比如select_contours_xld算子。

(4)、选择好了轮廓线后进行合并共圆轮廓和合并相邻轮廓操作,算子分别为union_cocircular_contours_xld和union_adjacent_contours_xld。

(5)、对合并好的轮廓可以拟合圆参数fit_circle_contour_xld。

(6)、产生圆gen_circle。

    select_obj (UnionContours, ObjectSelected, i)
    fit_circle_contour_xld (ObjectSelected, 'algebraic', -1, 0, 0, 3, 2, Row, Column, Radius, StartPhi, EndPhi, PointOrder)
    gen_circle_contour_xld (ContCircle, Row, Column, Radius, 0, rad(360), 'positive', 1.5)


2018-02-03   #3
get_region_runs (ObjectSelected, Row, ColumnBegin, ColumnEnd)

功能:查询一个区域的扫描宽度编码

   for C := 1 to NContours by 1
        select_obj (Contours, ObjectSelected, C)
        get_contour_xld (ObjectSelected, Row, Col)
        gen_cross_contour_xld (Cross, Row, Col, 12, rad(0))
        dev_set_color ('green')
        dev_display (Cross)
        dev_set_color ('blue')
        dev_display (ObjectSelected)
    endfor

get_contour_xld (Contour, Row, Col)是得到XLD中的一系列点; 

上面可以得到每根线的测量点.....然后画上XX

blob.png

2018-02-03   #4

预处理图像:

         对图像的某些预处理:使用mean_image或binomial_filter消除噪声;

         抑制小斑点或细线使用median_image;

         平滑图像可以使用smooth_image;

         如果又想平滑图像又想保存边缘,可以尝试anisotropic_diffusion;


2018-02-03   #5

skeleton (RegionClosing, Skeleton)

骨架轮廓提取

找出轮廓的骨架

提取之前的图片:

blob.png

执行之后:

blob.png

skeleton (RegionClosing, Skeleton)
gen_contours_skeleton_xld (Skeleton, ContoursSkeleton, 1, 'filter')
segment_contours_xld (ContoursSkeleton, ContoursSplitSkeleton, 'lines', 5, 2, 1)
select_contours_xld (ContoursSplitSkeleton, SelectedContours, 'contour_length', 30, 1000, -0.5, 0.5)
union_collinear_contours_xld (SelectedContours, UnionCollinearContours, 100, 10, 20, rad(10), 'attr_keep')

获取骨架

转换骨架为xld区域

转换xld区域为line线段

选择既定长度的xld线段

合并临近线段

登录后方可回帖

登 录
信息栏
 私人小站

本站域名

ChengXu.XYZ

投诉联系:  popdes@126.com



快速上位机开发学习,本站主要记录了学习过程中遇到的问题和解决办法及上位机代码分享

这里主要专注于学习交流和经验分享.
纯私人站,当笔记本用的,学到哪写到哪.
如果侵权,联系 Popdes@126.com

友情链接
Aardio官方
Aardio资源网


才仁机械


网站地图SiteMap

Loading...