VS2017 C#用halcon采集本地图片
2021-07-04 01:09
标签:ict isp threading 地图 open partial private and lin VS2017 C#用halcon采集本地图片 标签:ict isp threading 地图 open partial private and lin 原文地址:https://www.cnblogs.com/mayayun/p/9870153.htmlusing 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;
namespace ReadHalconImage
{
public partial class Form1 : Form
{
private HTuple WindowID;
private HObject Image;
public Form1()
{
InitializeComponent();
Image = new HObject();
CreateHalconWindow();
LoadImage();
}
public void CreateHalconWindow()
{
HTuple FatherWindow = this.DisplayVideo_pictureBox.Handle;
HOperatorSet.SetWindowAttr("background_color", "yellow");
HOperatorSet.OpenWindow(0, 0, this.DisplayVideo_pictureBox.Width, this.DisplayVideo_pictureBox.Height, FatherWindow, "visible", "", out WindowID);
}
public void LoadImage()
{
HOperatorSet.ReadImage(out Image, "1.bmp");
HTuple width = null, height = null;
HOperatorSet.GetImageSize(Image, out width, out height);
HOperatorSet.SetColor(WindowID, "yellow");
HOperatorSet.SetPart(WindowID, 0, 0, height, width);
HOperatorSet.DispObj(Image, WindowID);
}
}
}