资源简介
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 Nivisiontohob
----------- --------- ---------- ----- ----
105752 3
相关资源
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
- C#自定义控件
- 基于c#的实验室设备管理系统621530
- C# 使用ListView控件实现图片浏览器(源
- C#简单窗体聊天程序
- C#指纹识别系统程序 报告
- c# 高校档案信息管理系统
- c#向word文件插入图片
- C#左侧导航菜单(动态生成)
评论
共有 条评论