halcon-gen_contour_region_xld根据区域创建XLD轮廓


 

 

在HDevelop中

dev_close_window ()
read_image (Image, 'D:/bb/tu/4.jpg')
rgb1_to_gray (Image, GrayImage)

threshold (GrayImage, Region, 90, 95)
connection (Region, ConnectedRegions)
select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 12800, 12980)

gen_contour_region_xld (SelectedRegions, Contours, 'border')
*根据区域创建XLD轮廓(contour)
*参数1:输入区域
*参数2:输出轮廓
*参数3:轮廓生成模式
*       'border'           边界像素的外边界作为轮廓点
*       'border_holes'    除了输入区域的外边界,还可以得到所有孔的轮廓
*       'center'         边界像素的中心用作轮廓点



get_image_size (GrayImage, Width, Height)
dev_open_window(10,10,Width, Height,'black',WindowHandle3)
dev_display(Contours)

 

 

 


在QtCreator中

  HObject  ho_Image, ho_GrayImage, ho_Region, ho_ConnectedRegions;
  HObject  ho_SelectedRegions, ho_Contours;
  HTuple  hv_Width, hv_Height, hv_WindowHandle3;
  ReadImage(&ho_Image, "D:/bb/tu/4.jpg");
  Rgb1ToGray(ho_Image, &ho_GrayImage);

  Threshold(ho_GrayImage, &ho_Region, 90, 95);
  Connection(ho_Region, &ho_ConnectedRegions);
  SelectShape(ho_ConnectedRegions, &ho_SelectedRegions, "area", "and", 12800, 12980);

  GenContourRegionXld(ho_SelectedRegions, &ho_Contours, "border");
  //根据区域创建XLD轮廓(contour)
  //参数1:输入区域
  //参数2:输出轮廓
  //参数3:轮廓生成模式
  //      'border'           边界像素的外边界作为轮廓点
  //      'border_holes'    除了输入区域的外边界,还可以得到所有孔的轮廓
  //      'center'         边界像素的中心用作轮廓点



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

 

 

 

 

 

 

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM