VS2017 C#用halcon采集本地图片

时间:2018-10-29 13:41:33   收藏:0   阅读:648
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;

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);

}


}


}

 

原文:https://www.cnblogs.com/mayayun/p/9870153.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!