QQ登录

只需一步,快速开始

halcon union2_closed_contours_xld函数介绍

[ 复制链接 ]
union2_closed_contours_xld(Contours1, Contours2 : ContoursUnion : : )
计算Contours1, Contours2 所组成的闭合区域的并集,
并将结果区域的轮廓保存在ContoursUnion 。

同样可以执行下面例程查看调用 此函数生成的轮廓效果
gen_ellipse_contour_xld (Contour1, 200, 200, 0, 100, 100, 0, 6.28318, 'positive', 1.5)
gen_ellipse_contour_xld (Contour2, 200, 300, 0, 100, 100, 0, 6.28318, 'positive', 1.5)
*
* Now, the union of the two regions is determined.
union2_closed_contours_xld (Contour1, Contour2, ContoursUnion)
*
* Visualization of the result
dev_set_line_width (5)
dev_set_color ('green')
dev_display (Contour1)
dev_set_color ('red')
dev_display (Contour2)
dev_set_line_width (3)
dev_set_color ('blue')
dev_display (ContoursUnion)
stop ()
dev_clear_window ()
dev_set_line_width (1)
dev_set_color ('white')
*
* Now, boundary sets that define regions with holes are created.
gen_ellipse_contour_xld (Boundary1, 200, 200, 0, 100, 100, 0, 6.28318, 'positive', 1.5)
gen_ellipse_contour_xld (Hole1, 200, 200, 0, 75, 75, 0, 6.28318, 'positive', 1.5)
concat_obj (Boundary1, Hole1, BoundarySet1)
gen_ellipse_contour_xld (Boundary2, 200, 300, 0, 100, 100, 0, 6.28318, 'positive', 1.5)
gen_ellipse_contour_xld (Hole2, 200, 300, 0, 75, 75, 0, 6.28318, 'positive', 1.5)
concat_obj (Boundary2, Hole2, BoundarySet2)
*
* Now, the union of the two regions is determined.
union2_closed_contours_xld (BoundarySet1, BoundarySet2, ContoursUnion)
*
* Visualization of the result
dev_set_line_width (5)
dev_set_color ('green')
dev_display (BoundarySet1)
dev_set_color ('red')
dev_display (BoundarySet2)
dev_set_line_width (3)
dev_set_color ('blue')
dev_display (ContoursUnion)
*
* Note that last three contours in the result define holes in the first contour.
* This information is stored in the global contour attribute 'is_hole'.
count_obj (ContoursUnion, Number)
for Index := 1 to Number by 1
  select_obj (ContoursUnion, ObjectSelected, Index)
  get_contour_global_attrib_xld (ObjectSelected, 'is_hole', Attrib)
endfor


1.union2_closed_polygons_xld(Polygons1, Polygons2 : PolygonsUnion : : )
和上面函数相似的还有计算多边形轮廓并集。
对应也有一个实例,可以执行    查看生成的轮廓样子。
gen_ellipse_contour_xld (Contour1, 200, 200, 0, 100, 100, 0, 6.28318, 'positive', 1.5)
gen_polygons_xld (Contour1, Polygon1, 'ramer', 10)
gen_ellipse_contour_xld (Contour2, 200, 300, 0, 100, 100, 0, 6.28318, 'positive', 1.5)
gen_polygons_xld (Contour2, Polygon2, 'ramer', 10)
*
* Now, the union of the two regions is determined.
union2_closed_polygons_xld (Polygon1, Polygon2, PolygonsUnion)
*
* Visualization of the result
dev_clear_window ()
dev_set_line_width (5)
dev_set_color ('green')
dev_display (Polygon1)
dev_set_color ('red')
dev_display (Polygon2)
dev_set_line_width (3)
dev_set_color ('blue')
dev_display (PolygonsUnion)
stop ()
dev_clear_window ()
dev_set_line_width (1)
dev_set_color ('white')
*
* Now, boundary sets that define regions with holes are created.
gen_ellipse_contour_xld (Boundary1, 200, 200, 0, 100, 100, 0, 6.28318, 'positive', 1.5)
gen_polygons_xld (Boundary1, Boundary1Poly, 'ramer', 10)
gen_ellipse_contour_xld (Hole1, 200, 200, 0, 75, 75, 0, 6.28318, 'positive', 1.5)
gen_polygons_xld (Hole1, Hole1Poly, 'ramer', 10)
concat_obj (Boundary1Poly, Hole1Poly, BoundarySet1)
gen_ellipse_contour_xld (Boundary2, 200, 300, 0, 100, 100, 0, 6.28318, 'positive', 1.5)
gen_polygons_xld (Boundary2, Boundary2Poly, 'ramer', 10)
gen_ellipse_contour_xld (Hole2, 200, 300, 0, 75, 75, 0, 6.28318, 'positive', 1.5)
gen_polygons_xld (Hole2, Hole2Poly, 'ramer', 10)
concat_obj (Boundary2Poly, Hole2Poly, BoundarySet2)
*
* Now, the union of the two regions is determined.
union2_closed_polygons_xld (BoundarySet1, BoundarySet2, PolygonsUnion)
*
* Visualization of the result
dev_clear_window ()
dev_set_line_width (5)
dev_set_color ('green')
dev_display (BoundarySet1)
dev_set_color ('red')
dev_display (BoundarySet2)
dev_set_line_width (3)
dev_set_color ('blue')
dev_display (PolygonsUnion)

  

halcon从自学到接项目视频教程,另外再赠送全网最全资源  

  

欢迎围观我录制的一套halcon自学视频教程(进入)



回复

使用道具 举报

快速回复 返回列表 客服中心 搜索