VisionPro的CogRecordDisplay控件显示及保存图片

  1. CogRecordDisplay显示

CogImageFile ImageFile1 = new CogImageFile();
string imagepath;//图片路径
CogImage8Gray readimage =ImageFile1.Open(imagepath, CogImageFileModeConstants.Read);
cogRecordDisplay.image =readimage;
cogRecordDisplay.AutoFit = true;//自适应
  1. 清除CogRecordDisplay显示

cogRecordDisplay.Image = null;
cogRecordDisplay.StaticGraphics.Clear();
cogRecordDisplay.InteractiveGraphics.Clear();
  1. 保存原图

CogImageFileTool ImageFileTool = new CogImageFileTool();
string imagepath;//图片路径
ImageFileTool.Operator.Open(imagepath, CogImageFileModeConstants.Write);
ImageFileTool.InputImage = cogRecordDisplay.image;
ImageFileTool.Run();
ImageFileTool.Operator.Close();
  1. 保存CogRecordDisplay显示结果图像

string imagepath;//图片路径
Bitmap bitmap = CogRecordDisplay.CreateContentBitmap(Cognex.VisionPro.Display.CogDisplayContentBitmapConstants.Display) as Bitmap;
bitmap.Save(imagepath);

  • 0
    点赞
  • 36
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
在C#中实现VisionPro CogRecordDisplay功能,需要使用Cognex.VisionPro.Tool.CogRecordDisplay件。此件可用于显示CogRecord对象,该对象包含VisionPro工具生成的图像和数据。 下面是一个简单的示例代码,演示如何在C#中使用CogRecordDisplay件: ```csharp using Cognex.VisionPro.Tool; // 创建CogRecordDisplay对象 CogRecordDisplay cogRecordDisplay = new CogRecordDisplay(); // 设置件大小和位置 cogRecordDisplay.Size = new System.Drawing.Size(640, 480); cogRecordDisplay.Location = new System.Drawing.Point(10, 10); // 添加件到窗体中 this.Controls.Add(cogRecordDisplay); // 创建CogRecord对象 CogRecord cogRecord = new CogRecord(); // 添加图像和数据到CogRecord对象中 // 显示CogRecord对象 cogRecordDisplay.Image = cogRecord.SubRecords[0].Content as CogImage8Grey; cogRecordDisplay.Record = cogRecord; ``` 在上面的代码中,我们首先创建了一个CogRecordDisplay对象,然后设置了件的大小和位置,将其添加到窗体中。接着,我们创建了一个CogRecord对象,并将图像和数据添加到其中。最后,我们将CogRecord对象显示CogRecordDisplay件中。 需要注意的是,CogRecord对象中包含了多个子记录,每个子记录表示一个工具的输出结果。在上面的代码中,我们假设CogRecord对象中的第一个子记录包含了一个CogImage8Grey对象,因此我们将其作为CogRecordDisplay件的图像显示出来。如果CogRecord对象中有多个子记录,我们可以通过索引来获取不同的子记录,并显示CogRecordDisplay件中。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值