halcon与C#混合编程(二)读取并处理图片_第1页
halcon与C#混合编程(二)读取并处理图片_第2页
halcon与C#混合编程(二)读取并处理图片_第3页
halcon与C#混合编程(二)读取并处理图片_第4页
halcon与C#混合编程(二)读取并处理图片_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

示例:读取并处理图片源码:1:*读取图片2:read_image(Image,'D:/MyFile/C#/HalconCsExample/示例图片.jpg')3:get_image_size(Image,Width,Height)*图像处理rgb1_to_gray(Image,GrayImage)导出的代码():1://2://FilegeneratedbyHDevelopforHALCON/DOTNET(C#)Version10.03://4://ThisfileisintendedtobeusedwiththeHDevelopTemplateor5://HDevelopTemplateWPFprojectslocatedunder%HALCONEXAMPLES%\c#6:7:usingSystem;8:usingHalconDotNet;9:10:publicpartialclassHDevelopExport11:{12:publicHTuplehv_ExpDefaultWinHandle;13:14://Mainprocedure15:privatevoidaction(){18://Localiconicvariables19:20:HObjectho_Image,ho_GrayImage;23://Localcontrolvariables24:25:HTuplehv_Width,hv_Height;26:27://Initializelocalandoutputiconicvariables28:HOperatorSet.GenEmptyObj(outho_Image);29:HOperatorSet.GenEmptyObj(outho_GrayImage);30:31://读取图片32://dev_close_window(...);33:ho_Image.Dispose();34:HOperatorSet.ReadImage(outho_Image,"D:/MyFile/C#/HalconCsExample/示例图片.jpg");35:HOperatorSet.GetImageSize(ho_Image,outhv_Width,outhv_Height);36://dev_open_window(...);37:HOperatorSet.DispObj(ho_Image,hv_ExpDefaultWinHandle);38:39://图像处理40:ho_GrayImage.Dispose();41:HOperatorSet.Rgb1ToGray(ho_Image,outho_GrayImage);42:HOperatorSet.DispObj(ho_GrayImage,hv_ExpDefaultWinHandle);43:44:ho_Image.Dispose();45:ho_GrayImage.Dispose();TOC\o"1-5"\h\z}49:publicvoidInitHalcon()50:{51://DefaultsettingsusedinHDevelop52:HOperatorSet.SetSystem("do_low_error","false");}55:publicvoidRunHalcon(HTupleWindow)56:{57:hv_ExpDefaultWinHandle=Window;58:action();}}工程:1:usingSystem;2:usingSystem.Collections.Generic;3:usingSystem.ComponentModel;4:usingSystem.Data;5:usingSystem.Drawing;6:usingSystem.Linq;7:usingSystem.Text;8:usingSystem.Windows.Forms;9:10:usingHalconDotNet;//添加引用11:12:namespaceHalconCsExample13:{14:publicpartialclassForm1:Form15:{16://增加代码:17:HDevelopExportHD=newHDevelopExport();18:stringImagePath;19:20:publicForm1()TOC\o"1-5"\h\z{22:InitializeComponent();23:this.btnImagePro.Enabled=false;}26:privatevoidbtnReadImage_Click(objectsender,EventArgse){openFileDialogl.Filter="JPEG文件|*.jpg*|BMP文件|*.bmp*|TIFF文件|*.tiff*”;openFileDialog1.RestoreDirectory=true;openFileDialog1.FilterIndex=1;31:if(openFileDialog1.ShowDialog()==DialogResult.OK)TOC\o"1-5"\h\z{33:ImagePath=openFileDialog1.FileName;34:HD.ReadImage(hWindowControl1.HalconWindow,ImagePath);35:this.btnImagePro.Enabled=true;}}39:privatevoidbtnImagePro_Click(objectsender,EventArgse)40:{41:HD.ImagePro();42:this.btnImagePro.Enabled=false;}}46://从导出的ReadImage.cs中拷贝HDevelopExport类到命名空间HalconCsExample47:publicpartialclassHDevelopExport48:{49:publicHTuplehv_ExpDefaultWinHandle;50://Localiconicvariables51:HObjectho_Image,ho_GrayImage;

publicvoidInitHalcon(){//DefaultsettingsusedinHDevelopHOperatorSet.SetSystem("do_low_error","false");}publicvoidReadImage(HTupleWindow,stringpath){hv_ExpDefaultWinHandle=Window;//InitializelocalandoutputiconicvariablesHOperatorSet.GenEmptyObj(outho_Image);HOperatorSet.GenEmptyObj(outho_GrayImage);//读取图片//dev_close_window(...);ho_Image.Dispose();HOperatorSet.ReadImage(outho_Image,path);//dev_open_window(...);HOperatorSet.DispObj(ho_Image,hv_ExpDefaultWinHandle);}publicvoidImagePro(){//图像处理ho_GrayImage.Dispose();HOperatorSet.Rgb1ToGray(ho_Image,outho_GrayImage);HOperatorSet.DispObj(ho_GrayImage,hv_Exp

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论