本文已参与「新人创作礼」活动,一起开启掘金创作之路。
图像的采集以及曝光的设定
```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