visionPro图像与Halcon图像格式互相转换代码

//Halcon图像转VP图像*******************

HTuple type, width, height, pointer;

HalconDotNet.HOperatorSet.ReadImage(out ho_Image, OpenImageDialog.FileName);

HalconDotNet.HOperatorSet.GetImagePointer1(ho_Image, out pointer, out type, out width, out height);   //拿H图像的指针

CogImage8Root tmpCogImage8Root = new CogImage8Root();

tmpCogImage8Root.Initialize(width, height, (IntPtr)pointer, width, null);

CogImage8Grey outVproImage = new CogImage8Grey();

outVproImage.SetRoot(tmpCogImage8Root);

DisplayVP_Scource.Image = outVproImage; //显示转换后的图像到CogDisplay

//VP图像转Halcon图像****************************

pointer=outVproImage.Get8GreyPixelMemory(CogImageDataModeConstants.Read, 0, 0, outVproImage.Width, outVproImage.Height).Scan0;  //拿VP图像的指针

HalconDotNet.HOperatorSet.GenImage1(out ho_Image2, "byte", outVproImage.Width, outVproImage.Height, pointer);                   //创建H图像

hwindow = HWindowControl1.HalconWindow;

 HTuple hv_Width = new HTuple();

HTuple hv_Height = new HTuple();

HOperatorSet.GetImageSize(ho_Image2, out hv_Width, out hv_Height);

HOperatorSet.SetPart(hwindow, 0, 0, hv_Height, hv_Width);

HOperatorSet.DispObj(ho_Image2, hwindow);   //显示转换后的图像到HWindowControl

//**************************************************************

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值