在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 View
{
    public partial class Form1 : Form
    {
        private HTuple MainUI_Camera_WindowId;
        public HObject RawImage = new HObject();
        public Form1()
        {
            InitializeComponent();
            OpenWindow();
            LoadImage();
        }

        public void OpenWindow()
        {
            long m_lWindowRow = 0, m_lWindowColunu = 0;
            HTuple Farthrer_windowHandle = this.PicView1.Handle;

            HOperatorSet.SetWindowAttr("background_color", "blue");//设置窗口的背景颜色


            HOperatorSet.OpenWindow(m_lWindowRow, m_lWindowColunu, (HTuple)this.PicView1.Width, (HTuple)this.PicView1.Height, Farthrer_windowHandle, "visible", "", out MainUI_Camera_WindowId);       
        }
        
        public void LoadImage()
        {
            HOperatorSet.ReadImage(out RawImage, "FLAMING MOUNTAIN.JPG");

            HTuple width = null, height = null;

            HOperatorSet.GetImageSize(RawImage, out width, out height);

            HOperatorSet.SetColor(MainUI_Camera_WindowId, "yellow");

            HOperatorSet.SetPart(MainUI_Camera_WindowId, 0, 0, height, width);

            HOperatorSet.DispObj(RawImage, MainUI_Camera_WindowId);

            HOperatorSet.WriteString(MainUI_Camera_WindowId, "hellowWorld");

            HOperatorSet.SetTposition(MainUI_Camera_WindowId, width / 2, height / 2);


        }
    }
}

要点:在Debug目录下加入halcon.dll和halconnet.dll,缺一不可

然后haclon有32位和64位版本,64位理论上会比32位会快,如果你的halcon.是63位的那么编译过程就要选择x64编译,不能选any和x86。

发布了54 篇原创文章 · 获赞 14 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/bayinglong/article/details/84147213