ICogAcqFifo mAcqFifo;//定义一个相机对象
private ICogFrameGrabber mFrameGrabber = null;
CogFrameGrabberGigEs mframe = new CogFrameGrabberGigEs();
private void button1_Click(object sender, EventArgs e) //打开相机
{
int i = comboBox1.FindString(comboBox1.Text); //找到选择的下拉框tag
mAcqFifo = mframe[i].CreateAcqFifo(mframe[i].AvailableVideoFormats[0],
CogAcqFifoPixelFormatConstants.Format8Grey, 0, true);//初始化相机
cogRecordDisplay1.StartLiveDisplay(mAcqFifo, false);//控件绑定相机并显示画面
}
private void Form1_Load(object sender, EventArgs e)
{
if (mframe.Count < 1)
{
MessageBox.Show("没有找到相机设备!");
}
//遍历已连接相机信息,并添加进列表里(相机名,序列号,模式)
for (int i = 0; i < mframe.Count; i++)
{
mFrameGrabber = mframe[i];
comboBox1.Items.Add(mFrameGrabber.Name +
mFrameGrabber.SerialNumber+mFrameGrabber.AvailableVideoFormats[0]);
}
}