Halcon的一些简单的用法的介绍

本文已参与「新人创作礼」活动,一起开启掘金创作之路。

image.png

图像的采集以及曝光的设定

```js // Local iconic variables

HObject ho_Image=null;

// Local control variables 

HTuple hv_AcqHandle = null;
// Initialize local and output iconic variables 
HOperatorSet.GenEmptyObj(out ho_Image);
//Image Acquisition 01: Code generated by Image Acquisition 01
//Image Acquisition 01: Attention: The initialization may fail in case parameters need to
//Image Acquisition 01: be set in a specific order (e.g., image resolution vs. offset).
HOperatorSet.OpenFramegrabber("GigEVision2", 0, 0, 0, 0, 0, 0, "progressive", 
    -1, "default", -1, "false", "default", "GP130000016", 0, -1, out hv_AcqHandle);
HOperatorSet.SetFramegrabberParam(hv_AcqHandle, "Width", 1280);
HOperatorSet.SetFramegrabberParam(hv_AcqHandle, "Height", 1016);
HOperatorSet.SetFramegrabberParam(hv_AcqHandle, "OffsetX", 0);
HOperatorSet.SetFramegrabberParam(hv_AcqHandle, "PixelFormat", "Mono8");
HOperatorSet.SetFramegrabberParam(hv_AcqHandle, "TriggerLoopPeriod", 1000000);
HOperatorSet.SetFramegrabberParam(hv_AcqHandle, "ExposureTime", 4998.06);
HOperatorSet.GrabImageStart(hv_AcqHandle, -1);
while ((int)(1) != 0)
{
  ho_Image.Dispose();
  HOperatorSet.GrabImageAsync(out ho_Image, hv_AcqHandle, -1);
  //Image Acquisition 01: Do something
}
HOperatorSet.CloseFramegrabber(hv_AcqHandle);
ho_Image.Dispose();

```

铁钩位置的判断

C# 代码

```js // // File generated by HDevelop for HALCON/.NET (C#) Version 18.11.0.1 // 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 !(NOEXPORTMAIN || NOEXPORTAPP_MAIN)

public HDevelopExport() { // Default settings used in HDevelop HOperatorSet.SetSystem("width", 512); HOperatorSet.SetSystem("height", 512); if (HalconAPI.isWindows) HOperatorSet.SetSystem("usewindowthread","true"); action(); }

endif

// Procedures // Chapter: Develop // Short Description: Open a new graphics window that preserves the aspect ratio of the given image size. public void devopenwindowfitsize (HTuple hvRow, HTuple hvColumn, HTuple hvWidth, HTuple hvHeight, HTuple hvWidthLimit, HTuple hvHeightLimit, out HTuple hv_WindowHandle) {

// Local iconic variables 

// Local control variables 

HTuple hv_MinWidth = new HTuple(), hv_MaxWidth = new HTuple();
HTuple hv_MinHeight = new HTuple(), hv_MaxHeight = new HTuple();
HTuple hv_ResizeFactor = new HTuple(), hv_TempWidth = new HTuple();
HTuple hv_TempHeight = new HTuple(), hv_WindowWidth = new HTuple();
HTuple hv_WindowHeight = new HTuple();
// Initialize local and output iconic variables 
hv_WindowHandle = new HTuple();
//This procedure open a new graphic window
//such that it fits into the limits specified by WidthLimit
//and HeightLimit, but also maintains the correct aspect ratio
//given by Width and Height.
//
//If it is impossible to match the minimum and maximum extent requirements
//at the same time (f.e. if the image is very long but narrow),
//the maximum value gets a higher priority.
//
//Parse input tuple WidthLimit
if ((int)((new HTuple((new HTuple(hv_WidthLimit.TupleLength())).Tu
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

宋小童

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值