HALCON:Programming With HALCON/.NET

HALCON:Programming With HALCON/.NET

1. the minimum requirements and capabilities of the different HALCON interface variants

Table indicates the minimum requirements and capabilities of the different HALCON interface variants.

 

2. Adding HALCON/.NET to an Application

To leverage the cross-platform nature of .NET Core, the interface is offered in two package variants. Both of them contain the complete HALCON/.NET and HDevEngine/.NET language bindings.

MVTec.HalconDotNet: This package targets .NET Standard 2.0 and can be used on all architectures supported by HALCON.

MVTec.HalconDotNet-Windows: This package targets .NET Core 3.1 and additionally includes Windows Forms and WPF controls for integrating HALCON windows into GUI applications. This package can only be used on Windows since other .NET Core 3.1 implementations do not offer Windows Forms or WPF support.

HALCON/.NET is not a self-contained package but an interface to the native HALCON library. Therefore, the package version used by your project has to match the installed HALCON version exactly.

Even for maintenance releases, which are backwards compatible at application level, mixing of binaries from different releases is not recommended because the internal communication between HALCON/.NET and the native HALCON library is not guaranteed to be always compatible. Therefore, the revision of the HALCON release is also part of the SemVer major version. The SemVer minor and patch version are reserved for fully backwards-compatible intermediate releases of the package itself. See section “.NET Core” for updating dependencies.

3. Customizing Visual Studio's Toolbox

The HALCON/.NET assembly provides not only a class library but also one control: HSmartWindowControl (or HSmartWindowControlWPF), which contains a HALCON graphics window for visualizing images and results.

The older control HWindowControl is still available for backwards compatibility but it is strongly advised against using this control for new projects (see section “Window Controls for Visualization” for information about the differences).

You can add these controls to Visual Studio's toolbox by performing the following steps. Note that the exact menu names slightly differ in different versions of Visual Studio:

  1. Right-click the toolbox and select Choose Items (Customize Toolbox in previous versions of Visual Studio). This will open a dialog displaying all available .NET Framework components in a tab.
  2. Click Browse, navigate to the directory %HALCONROOT%\bin\dotnet20 (Visual Studio 2005) or %HALCONROOT%\bin\dotnet35 (Visual Studio 2008 or higher) and select HALCON/.NET DLL.


  3. The icon of HSmartWindowControl and the older HWindowControl appear in the toolbox.

HALCON XL applications: When developing an application with HALCON XL, select HALCON/.NET XL DLL instead of HALCON/.NET DLL. In the toolbox, the control appears with the same name but with a different icon. You can add both HALCON versions to the toolbox but only one of them to an application.

 4. Deploying an Application

1. Do not modify the “Brush” properties in Visual Studio. They are disabled for HSmartWindowControlWPF to prevent undesired side-effects.

2. The HSmartWindowControlWPF can be used to implement the Model-View-Viewmodel (MVVM) pattern, as all properties of the control support data binding. By adding objects to the Items collection or setting the ItemsSource property you can specify what the control should display, also in pure XAML code. The following example illustrates how to show an image, color a region in “magenta”, and display a text message:

<HalconDotNet:HSmartWindowControlWPF HDraw="fill">
  <!--Iconic items can be added using HIconicDisplayObjectWPFs-->
  <HalconDotNet:HIconicDisplayObjectWPF IconicObject="{Binding DisplayImage}"/>
  <!--Also with individual drawing properties-->
  <HalconDotNet:HIconicDisplayObjectWPF IconicObject="{Binding DisplayRegion}"
  HDraw="margin" HColor="magenta"/>
  <!--Messages can be displayed using HMessageDisplayObjectWPFs-->
  <HalconDotNet:HMessageDisplayObjectWPF HMessageText="{Binding ImageName}"/>
</HalconDotNet:HSmartWindowControlWPF>
Note that DisplayImage, DisplayRegion and ImageName have to exist in the DataContext of the HSmartWindowControlWPF.

转载自:https://blog.csdn.net/liubing8609/article/details/126197485

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值