halcon程序导出和C#环境配置

halcon程序导出和C#环境配置

read_image (Image, 'E:/cat.png')
rgb1_to_gray (Image, GrayImage)
threshold (GrayImage, Region, 128, 255)

在这里插入图片描述
在这里插入图片描述

//
// File generated by HDevelop for HALCON/.NET (C#) Version 18.11.1.0
// Non-ASCII strings in this file are encoded in local-8-bit encoding (cp936).
// 
// Please note that non-ASCII characters in string constants are exported
// as octal codes in order to guarantee that the strings are correctly
// created on all systems, independent on any compiler settings.
// 
// Source files with different encoding should not be mixed in one project.
//

using HalconDotNet;

public partial class HDevelopExport
{
#if !(NO_EXPORT_MAIN || NO_EXPORT_APP_MAIN)
  public HDevelopExport()
  {
    // Default settings used in HDevelop
    HOperatorSet.SetSystem("width", 512);
    HOperatorSet.SetSystem("height", 512);
    if (HalconAPI.isWindows)
      HOperatorSet.SetSystem("use_window_thread","true");
    action();
  }
#endif

#if !NO_EXPORT_MAIN
  // Main procedure 
  private void action()
  {


    // Local iconic variables 

    HObject ho_Image, ho_GrayImage, ho_Region;
    // Initialize local and output iconic variables 
    HOperatorSet.GenEmptyObj(out ho_Image);
    HOperatorSet.GenEmptyObj(out ho_GrayImage);
    HOperatorSet.GenEmptyObj(out ho_Region);

    HOperatorSet.ReadImage(out ho_Image, "E:/cat.png");
    HOperatorSet.Rgb1ToGray(ho_Image, out ho_GrayImage);
    HOperatorSet.Threshold(ho_GrayImage, out ho_Region, 128, 255);
	
	
    ho_Image.Dispose();
    ho_GrayImage.Dispose();
    ho_Region.Dispose();


  }

#endif


}
#if !(NO_EXPORT_MAIN || NO_EXPORT_APP_MAIN)
public class HDevelopExportApp
{
  static void Main(string[] args)
  {
    new HDevelopExport();
  }
}
#endif


  private void action()
  {


    // Local iconic variables 

    HObject ho_Image, ho_GrayImage, ho_Region;
    // Initialize local and output iconic variables 
    HOperatorSet.GenEmptyObj(out ho_Image);
    HOperatorSet.GenEmptyObj(out ho_GrayImage);
    HOperatorSet.GenEmptyObj(out ho_Region);

    HOperatorSet.ReadImage(out ho_Image, "E:/cat.png");
    HOperatorSet.Rgb1ToGray(ho_Image, out ho_GrayImage);
    HOperatorSet.Threshold(ho_GrayImage, out ho_Region, 128, 255);
	
	
    ho_Image.Dispose();
    ho_GrayImage.Dispose();
    ho_Region.Dispose();


  }

Winform

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

C:\Program Files\MVTec\HALCON-18.11-Steady\bin\dotnet35

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

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;

namespace Learning4Halcon
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            // Local iconic variables 

            HObject ho_Image, ho_GrayImage, ho_Region;
            // Initialize local and output iconic variables 
            HOperatorSet.GenEmptyObj(out ho_Image);
            HOperatorSet.GenEmptyObj(out ho_GrayImage);
            HOperatorSet.GenEmptyObj(out ho_Region);

            HOperatorSet.ReadImage(out ho_Image, "E://cat.png");
            HOperatorSet.Rgb1ToGray(ho_Image, out ho_GrayImage);
            HOperatorSet.Threshold(ho_GrayImage, out ho_Region, 128, 255);

            hWindowControl1.HalconWindow.DispObj(ho_GrayImage);
            hWindowControl1.HalconWindow.DispObj(ho_Region);

            ho_Image.Dispose();
            ho_GrayImage.Dispose();
            ho_Region.Dispose();
        }
    }
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值