|
halcon生成C++版代码,封装为dll,供C#调用:
具体链接:
C#窗体程序--调用代码:
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using HalconDotNet;
- using System.Runtime.InteropServices;
- namespace CED_CSharp
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- HObject ho_Image,ho_GrayImage, ho_ImageCED, ho_DiffOfGauss;
- HTuple ImagePath = @"C:/Users/ysw/Desktop/视频讲解/图像处理视频Halcon/Halcon图像处理-edit/logo3.jpg";
- HTuple hv_Width = null, hv_Height = null, hv_Sigma1 = null, hv_Sigma2 = null;
- HOperatorSet.ReadImage(out ho_Image, ImagePath);
- HOperatorSet.Rgb1ToGray(ho_Image, out ho_GrayImage);
- HOperatorSet.GetImageSize(ho_GrayImage, out hv_Width, out hv_Height);
- hv_Sigma1 = 0.5;
- hv_Sigma2 = 3;
- HOperatorSet.GenEmptyObj(out ho_ImageCED);
- HOperatorSet.GenEmptyObj(out ho_DiffOfGauss);
- if (CED_CSharp.LoadDLL.CED_LoG(ho_Image, out ho_ImageCED, out ho_DiffOfGauss, hv_Sigma1, hv_Sigma2))
- {
- HOperatorSet.SetPart(hWindowControl1.HalconWindow, 0, 0, hv_Height - 1, hv_Width - 1);
- HOperatorSet.DispObj(ho_Image, hWindowControl1.HalconWindow);
- HOperatorSet.SetPart(hWindowControl2.HalconWindow, 0, 0, hv_Height - 1, hv_Width - 1);
- HOperatorSet.DispObj(ho_ImageCED, hWindowControl2.HalconWindow);
- HOperatorSet.SetPart(hWindowControl3.HalconWindow, 0, 0, hv_Height - 1, hv_Width - 1);
- HOperatorSet.DispObj(ho_DiffOfGauss, hWindowControl3.HalconWindow);
- }
- else
- {
- MessageBox.Show("CED_LoG算法调用有误!!!");
- }
- //HOperatorSet.CoherenceEnhancingDiff(ho_Image, out ho_ImageCED, hv_Sigma1, 4, 0.5, 50);
- //HOperatorSet.DiffOfGauss(ho_ImageCED, out ho_DiffOfGauss, hv_Sigma2, 1.6);
- //HOperatorSet.SetPart(hWindowControl2.HalconWindow, 0, 0, hv_Height - 1, hv_Width - 1);
- //HOperatorSet.DispObj(ho_ImageCED, hWindowControl2.HalconWindow);
- //HOperatorSet.SetPart(hWindowControl3.HalconWindow, 0, 0, hv_Height - 1, hv_Width - 1);
- //HOperatorSet.DispObj(ho_DiffOfGauss, hWindowControl3.HalconWindow);
- }
- }
- }
复制代码
|
|