前言:
Halcon视觉,一般与C#联合编程,才可将具体的功能应用到Windows桌面APP上。
案例:
将读取图片的功能,用桌面APP实现。
代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HalconDotNet;
namespace WindowsFormsApplication5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//读取图片按钮
private void button1_Click(object sender, EventArgs e)
{
HObject ho_Image;
HOperatorSet.GenEmptyObj(out ho_Image);
HOperatorSet.ReadImage(out ho_Image, "C:/Users/Administrator/Desktop/图片/电路板.png");
hWindowControl1.HalconWindow.DispObj(ho_Image);
ho_Image.Dispose();
}
}
}
效果:
结语:
桌面APP可嵌入Halcon视觉功能,应用场景将会更加广泛。