VS2017 C#用halcon采集本地图片

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

}


}


}

 

posted @ 2018-10-29 13:26  mayayun  阅读(1007)  评论(0)    收藏  举报