91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 88KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-10
  • 語言: C#
  • 標簽: C#??Labview??halcon??

資源簡介

C#代碼 NIVision Image To HalconImaget圖像格式轉換,直接輸入NI vision圖像轉換為Hobject類型

資源截圖

代碼片段和文件信息

//NationalInstruments.Vision.dll
//NationalInstruments.Vision.Common.dll
//NationalInstruments.Vision.Acquisition.Imaqdx.dll

using?NationalInstruments.Vision;
using?NationalInstruments.Vision.Analysis;
using?NationalInstruments;
using?System;
using?HalconDotNet;
using?Microsoft;
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?System.Management;


namespace?NIVIOSN
{
????public?class?NI_VISION
????{
????????public?void?VisionImage2Hobject(VisionImage?Image)
????????{
????????????

????????????//VisionImage?Image?=?new?VisionImage();
????????????PixelValue2D?p2D;???????

????????????p2D?=?Image.ImageToArray();

????????????Byte[]?imagedata?=?null;

????????????///?byte二維數組轉一維數組
????????????///
????????????imagedata?=?ByteArrToByte(p2D.U8?Image.Height?Image.Width);?//p2D.U8按行列排序的
????????????Hobject?hImage?=?new?HalconDotNet.Hobject();
????????????IntPtr?jj?=?new?IntPtr();

????????????///byte()轉IntPrt??CSDN關鍵字“在VB.Net中使用指針”
????????????//以下語句告訴net垃圾回收進程不對tabytTest進行處理,也就是說tabytTest占用的內存區域固定不變。
????????????System.Runtime.InteropServices.GCHandle?thobject?=?System.Runtime.InteropServices.GCHandle.Alloc(imagedata?System.Runtime.InteropServices.GCHandleType.Pinned);
????????????IntPtr?tpobject?=?thobject.AddrOfPinnedobject();?//取得指向字節數組的指針

????????????HalconDotNet.HOperatorSet.GenImage1(out?hImage?“byte“?Image.Width?Image.Height?tpobject);
????????????//HalconDotNet.HOperatorSet.WriteImage(hImage?“bmp“?0?Application.StartupPath?&?“\AOI?Image\“?&?“_H“?&?I?&?“.bmp“);


????????????//????//在使用完畢后一定要釋放指針指向的內存塊,讓垃圾回收器可對這個內存塊回收處理
????????????//if?(thobject.IsAllocated)
????????????//????thobject.Free();


????????????Image.Dispose();
????????}
????????//Cam(0).TriggerSource?=?NiCamera.TriggerSourceType.Software;
????????//Getimage_Busy(0)?=?False;

????????//????else
????????//????????//Threading.Thread.Sleep(10);

????????//catch?(Exception?ex)
????????//{
????????//????MsgBox(ex.ToString);


????????//Halcon圖像Hobject轉NIVision圖像VisionImage,步驟倒過來就好了:


//????????public?void?HImageToNivision(Hobject?hImage?out?HTuple??Pointer?out?HTuple?Width?out?HTuple?Height?)



//????????{


????????????

//????????????///?byte二維數組轉一維數組
//????????????///
????????????
???????????

//????????????HTuple??Type?=?“byte“;
//HOperatorSet.GetImagePointer1(hImage?out?Pointerout?Type?out?Width?out?Height);

//????????????//將Pointer轉byte[]

//????????????//將byte[]轉byte[]
???????????

//????????????PixelValue2D?p2D.U8=ByteArrToByte(Byte[]?b?Height[0].I()?Width[0].I());?//byte一維數組轉二維數組

//????????????ArrayToImage(p2D);
????????????//————————————————
????????????//版權聲明:本文為CSDN博主「c1learning」的原創文章,遵循?CC?4.0?BY-SA?版權協議,轉載請附上原文出處鏈接及本聲明。
????????????//原文鏈接:https://blog.csdn.net/c1learning/article/details/10073666

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件???????9607??2019-09-16?14:27??class.jpg

?????文件??????87945??2019-09-16?14:28??class2.jpg

?????文件???????8200??2019-09-16?13:58??Nivisiontohobject.cs

-----------?---------??----------?-----??----

???????????????105752????????????????????3


評論

共有 條評論