Halcon中 有两种参数类型:
分为 Iconic 与 Control. Iconic 为图片, control 为a1 b2
这两种, 每一种又分为输入和输出两种参数
固定参数顺序
input Iconic
output Iconic
input control
output control
using HalconDotNet;
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 System.Threading;
namespace CsharpHaldemon2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
#region HObject 转换为 HImage
private void HobjectToHimage(HObject hobject, ref HImage image)
{
HTuple pointer, type, width, height;
HOperatorSet.GetImagePointer1(hobject, out pointer, out type, out width, out height);
image.GenImage1(type, width, height, pointer);
}
#endregion
#region 设置图片与窗口等比例
private void WindowAdaptation(int width,int height, out HTuple row1, out HTuple column1, out HTuple row2, out HTuple column2)
{
double ratioWidth = (1.0) * width / hWindowControl1.Width;
double ratioHeight = (1.0) * height / hWindowControl1.Height;
if (ratioWidth > ratioHeight)
{
row1 = -(1.0) * ((hWindowControl1.Height * ratioWidth) - height) / 2;
column1 = 0;
row2 = row1 + hWindowControl1.Height * ratioWidth;
column2 = column1 + hWindowControl1.Width * ratioWidth;
}
else
{
row1 = 0;
column1 = -(1.0) * ((hWindowControl1.Width * ratioHeight) - width) / 2;
row2 = row1 + hWindowControl1.Height * ratioHeight;
column2 = column1 + hWindowControl1.Width * ratioHeight;
}
}
#endregion
private CancellationTokenSource cts = new CancellationTokenSource();
private CancellationTokenSource cts1 = new CancellationTokenSource();
private void btnOpenPic_Click(object sender, EventArgs e)
{
//HObject ho_Image, ho_ROI_0, ho_Cross;
/

本文介绍了如何使用Halcon在C#中实现摄像头捕获、图像预处理、边缘检测,并展示了仿射变换和XLD轮廓提取技术。通过实例代码展示了从打开相机到显示处理结果的全过程。
最低0.47元/天 解锁文章
1104

被折叠的 条评论
为什么被折叠?



