C# halcon 导出库工程(引擎方式导入)

  • Post author:
  • Post category:其他




资源文件

链接:https://pan.baidu.com/s/1HKAkeNOQEdcvGwGNjKygFQ

提取码:wm95

在这里插入图片描述



1.创建C#项目



创建C#项目,需要导入dll

halcondotnet.dll
hdevenginedotnet.dll

在这里插入图片描述

在这里插入图片描述



2.创建halcon项目



创建并定义函数

在这里插入图片描述

* Image 输入图片
* Region1 输出区域
* low 二值化阈值
* Area 区域面积
EFunTest (Image, Region1, low, Area)



主程序

read_image (Image, 'printer_chip/printer_chip_01')
low := 100
EFunTest (Image, Region1, low, Area)



子程序 EFunTest

threshold (Image, Region, low, 255)
area_center (Region, Area, Row, Column)
connection (Region, ConnectedRegions)
select_shape_std (ConnectedRegions, selectRegion, 'max_area', 70)

opening_circle (selectRegion, RegionOpen, 18.5)
dilation_circle (RegionOpen, Region, 13.5)

return ()



3.导出库工程

在这里插入图片描述

请添加图片描述



导出文件夹内容

请添加图片描述

res_HdevCallFunTest 存放.hdev文件
source              存放 C#加载程序



4.C#项目 添加加载工程代码



添加代码文件 HdevCallFunTest.cs

在这里插入图片描述



5.拷贝导出文件到,工程文件夹

在这里插入图片描述



6.调用与测试

  private void HdevFunExe(HImage imgOrg)
  {
      // 导出函数调用
      EngineFun.HdevCallFunTest.EFunTest(
          imgOrg,                         // 处理图片
          out HObject hResultRegion,      // 输出区域
          100.0,                          // 二值化参数
          out HTuple outArea              // 输出面积
          );

      // 显示图片
      this.hSmartWindowControl1.HalconWindow.DispObj(imgOrg);
      this.hSmartWindowControl1.SetFullImagePart();

      // 显示结果
      this.hSmartWindowControl1.HalconWindow.SetColor("blue");
      this.hSmartWindowControl1.HalconWindow.SetDraw("margin");
      this.hSmartWindowControl1.HalconWindow.SetLineWidth(4);
      this.hSmartWindowControl1.HalconWindow.DispObj(hResultRegion);
  }



版权声明:本文为weixin_45875105原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。