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 exercise01
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
HImage ho_Image = new HImage();
HRegion ho_ROI_0 = new HRegion();
HXLDCont ho_Cross = new HXLDCont();
ho_Image.ReadImage(@"F:\CYG\VirtualProject\python\162804194.jpg"); //读取图像
int width, height;
ho_Image.GetImageSize(out width, out height);
//显示图像
hWindowControl1.HalconWindow.SetPart(0, 0, height, width); //先高度再宽度,没有按比例显示
hWindowControl1.HalconWindow.DispObj(ho_Image);
//显示region
ho_ROI_0.GenRectangle1(100.0, 100, 250, 250);
ho_Image.DispImage(hWindowControl1.HalconWindow);
hWindowControl1.HalconWindow.SetColor("red");
ho_ROI_0.DispRegion(hWindowControl1.HalconWindow);
}
private void button2_Click(object sender, EventArgs e)
{
hWindowControl1.Focus(); //光标
hWindowControl1.HalconWindow.DrawCircle(out double row, out double column, out double radius);
HRegion region = new HRegion();
region.GenCircle(row, column, radius);
hWindowControl1.HalconWindow.SetColor("green");
region.DispRegion(hWindowControl1.HalconWindow);
}
private void button3_Click(object sender, EventArgs e)
{
hWindowControl1.Focus(); //光标
hWindowControl1.HalconWindow.DrawRectangle1(out double row1, out double column1, out double row2, out double column2);
HRegion region = new HRegion();
region.GenRectangle1(row1, column1, row2, column2);
hWindowControl1.HalconWindow.SetColor("blue");
region.DispRegion(hWindowControl1.HalconWindow);
}
}
}
2021-08-09C#联合halcon--画圆画矩形
最新推荐文章于 2024-02-21 13:02:26 发布