QQ登录

只需一步,快速开始

halcon symm_difference_closed_contours_xld函数介绍

[ 复制链接 ]
symm_difference_closed_contours_xld(Contours1, Contours2 : ContoursDifference : : )
计算Contours1, Contours2 所组成闭合区域的对称差集,
结果的轮廓保存于ContoursDifference 。
如果单个输入轮廓没有闭合,则通过连接它们的起点和终点使它们闭合。

执行halcon自带的例程,查看效果
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)
difference_closed_contours_xld (Contour1, Contour2, ContoursDifference0)
symm_difference_closed_contours_xld (Contour1, Contour2, ContoursDifference)
count_obj (ContoursDifference, Number)
for Index := 1 to Number by 1
  select_obj (ContoursDifference, ObjectSelected, Index)
  get_contour_global_attrib_xld (ObjectSelected, 'is_hole', Attrib)
endfor
*
* 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 (ContoursDifference)
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 symmetric difference of the two regions is determined.
symm_difference_closed_contours_xld (BoundarySet1, BoundarySet2, ContoursDifference)
*
* 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 (ContoursDifference)

1.symm_difference_closed_polygons_xld(Polygons1, Polygons2 : PolygonsDifference : : )
和上面函数相似,此函数计算的是多边形轮廓对称差集。
下边为halcon自带例程
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 symmetric difference of the two regions is determined.
symm_difference_closed_polygons_xld (Polygon1, Polygon2, PolygonsDifference)
*
* 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 (PolygonsDifference)
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 symmetric difference of the two regions is determined.
symm_difference_closed_polygons_xld (BoundarySet1, BoundarySet2, PolygonsDifference)
*
* 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 (PolygonsDifference)


  

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

  

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







回复

使用道具 举报

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