halcon-select_shape_xld根据形状特征选择轮廓

 

 

在HDevelop中

复制代码
dev_close_window ()
read_image (Image, 'D:/bb/tu/6.jpg')
rgb1_to_gray (Image, GrayImage)

edges_sub_pix (GrayImage, Edges, 'canny', 1, 5, 10)
*亚像素边缘

select_shape_xld (Edges, SelectedXLD, 'area', 'and', 5500, 5600)
*根据形状特征选择轮廓
*参数1:轮廓集
*参数2:选中的轮廓
*参数3:形状特征
*      'area':      轮廓的面积---默认
*      'area_points':   轮廓点的面积
*      'row':      中心的行索引
*      'column':    中心的列索引
*      'width':     轮廓的宽度
*      'height':    轮廓的高度
*      'ratio':     轮廓的高度与宽度之比
*      'row1':      左上角的行坐标
*      'column1':   左上角的列坐标
*      'row2':      右下角的行坐标
*      'column2':   右下角的列坐标
*      'circularity':   圆度
*      'compactness':    紧凑度
*      'contlength':    轮廓总长度
*      'convexity':    凸性
*      'ra':          等效椭圆的大半径
*      'rb':        等效椭圆的小半径
*      'phi':      等效椭圆的方向
*      'outer_radius':    最小外接圆半径
*      'max_diameter':    最大直径
*      'orientation':    轮廓的方向--弧度为单位
*      'rect2_phi':     最小外接矩形角度
*      'rect2_len1':    最小外接矩形长度的一半
*      'rect2_len2':    最小外接矩形宽度的一半
*参数4:特征之间的逻辑关系  (and or)
*参数5和参数6:Min,Max特征值的要求范围


get_image_size (GrayImage, Width, Height)
dev_open_window(10,10,Width, Height,'black',WindowHandle)
dev_display(Edges)

dev_open_window(10,10,Width, Height,'black',WindowHandle1)
dev_display(SelectedXLD)
复制代码

 

 

 


在QtCreator中

  HObject  ho_Image, ho_GrayImage, ho_Edges, ho_SelectedXLD;
  HTuple  hv_Width, hv_Height, hv_WindowHandle;
  HTuple  hv_WindowHandle1;
复制代码
  ReadImage(&ho_Image, "D:/bb/tu/6.jpg");
  Rgb1ToGray(ho_Image, &ho_GrayImage);

  EdgesSubPix(ho_GrayImage, &ho_Edges, "canny", 1, 5, 10);
  //亚像素边缘

  SelectShapeXld(ho_Edges, &ho_SelectedXLD, "area", "and", 5500, 5600);
  //根据形状特征选择轮廓
  //参数1:轮廓集
  //参数2:选中的轮廓
  //参数3:形状特征
  //     'area':      轮廓的面积---默认
  //     'area_points':   轮廓点的面积
  //     'row':      中心的行索引
  //     'column':    中心的列索引
  //     'width':     轮廓的宽度
  //     'height':    轮廓的高度
  //     'ratio':     轮廓的高度与宽度之比
  //     'row1':      左上角的行坐标
  //     'column1':   左上角的列坐标
  //     'row2':      右下角的行坐标
  //     'column2':   右下角的列坐标
  //     'circularity':   圆度
  //     'compactness':    紧凑度
  //     'contlength':    轮廓总长度
  //     'convexity':    凸性
  //     'ra':          等效椭圆的大半径
  //     'rb':        等效椭圆的小半径
  //     'phi':      等效椭圆的方向
  //     'outer_radius':    最小外接圆半径
  //     'max_diameter':    最大直径
  //     'orientation':    轮廓的方向--弧度为单位
  //     'rect2_phi':     最小外接矩形角度
  //     'rect2_len1':    最小外接矩形长度的一半
  //     'rect2_len2':    最小外接矩形宽度的一半
  //参数4:特征之间的逻辑关系  (and or)
  //参数5和参数6:Min,Max特征值的要求范围


  GetImageSize(ho_GrayImage, &hv_Width, &hv_Height);
  SetWindowAttr("background_color","black");
  OpenWindow(10,10,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle);
  HDevWindowStack::Push(hv_WindowHandle);
  if (HDevWindowStack::IsOpen())
    DispObj(ho_Edges, HDevWindowStack::GetActive());

  SetWindowAttr("background_color","black");
  OpenWindow(10,10,hv_Width,hv_Height,0,"visible","",&hv_WindowHandle1);
  HDevWindowStack::Push(hv_WindowHandle1);
  if (HDevWindowStack::IsOpen())
    DispObj(ho_SelectedXLD, HDevWindowStack::GetActive());
复制代码

 

 

 

 

 

posted @   天子骄龙  阅读(2716)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
历史上的今天:
2019-03-13 C++ 成员指针---了解
点击右上角即可分享
微信分享提示

目录导航