This sample demonstrates how to create a new ICogAcqFifo operator for a given video format. The CogAcqFifoTool does not acquire images by itself. Instead it uses the ICogAcqFifo to acquire images.
此示例演示如何为给定的视频格式创建新的 ICogAcqFifo operator。 CogAcqFifoTool 本身不获取图像。 相反,它使用 ICogAcqFifo 来获取图像。
When the user wants to change the video format, a new ICogAcqFifo must be created. The sample displays an error and exits if it cannot locate a frame grabber. This is because the frame grabber creates the ICogAcqFifo.
当用户想要改变视频格式时,必须创建一个新的 ICogAcqFifo。 如果无法找到图像采集卡,该示例会显示错误并退出。 这是因为图像采集卡创建了 ICogAcqFifo。
The sample will acquire an image when the Acquire button is pressed and display on the CogDisplay.
当按下获取按钮并显示在 CogDisplay 上时,示例将获取图像。
This program assumes that you have some knowledge of C# and VisionPro programming.
本程序假定您具有一些 C# 和 VisionPro 编程知识。
The following steps show how to create a new CogAcqFifo operator.
Step 1) Create the CogFrameGrabbers. Make sure there is at least one Cognex frame grabber on the system.
Step 2) Select the first frame grabber.
Step 3) Create an ICogAcqFifo operator with the selected video format.
Step 4) Acquire an image and display it when the Acquire button is pressed.
以下步骤展示了如何创建一个新的 CogAcqFifo 运算符。
步骤 1) 创建 CogFrameGrabbers。 确保系统上至少有一个 Cognex 图像采集卡。
步骤 2) 选择第一个图像采集卡。
步骤 3) 使用选定的视频格式创建一个 ICogAcqFifo 运算符。
步骤 4) 获取图像并在按下获取按钮时显示它。
Note that the .NET garbage collector is called every 5th image to free up images that are being held on the heap.
请注意,每 5 个图像调用 .NET 垃圾收集器以释放堆中保存的图像。
在 Form1.Designer.cs 中,添加 dispose的内容
using Cognex.VisionPro;
if (disposing)
{
CogFrameGrabbers frameGrabbers = new CogFrameGrabbers();
foreach (ICogFrameGrabber fg in frameGrabbers)
fg.Disconnect(false);
}