C#利用NI VAS采集图片

本文介绍如何在C#环境下利用National Instruments的Vision Acquisition Software进行图像采集与处理。主要内容包括:软件环境配置、在线相机获取、相机开启与关闭、图像拍摄及显示等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

软件环境

Vision Acquisition Software:该软件为NI视觉采集集成环境

  1. 新建C#工程
  2. 添加引用(位于’C:\Program Files (x86)\National Instruments\MeasurementStudioVS2008\DotNET\Assemblies\Current’文件夹下)
  • NationalInstruments.Common
  • NationalInstruments.Vision.Common
  • NationalInstruments.Vision.Aquisition.Imaqdx
  1. 获得在线的所有相机
	ImaqdxCameraInformation[] cameraList = ImaqdxSystem.GetCamerInformation(true);
  1. 打开所有相机
public bool OpenCameraDevice()
{
	try
	{
		List<ImaqdxSession> cameraSessionList = new List<ImaqdxSession>();
		foreach(var camera in cameraList)
		{
			cameraSessionList.Add(new ImaqdxSession(camera.Name));
			return true;
		}
	}
	catch()
	{
		return false;
	}
}
  1. 关闭所有相机
public void CloseCameraDevice()
{
	foreach(ImaqdxSession session in cameraSessionList)
	{
		if(session != null)
			session.Close();
	}
}
  1. 拍照及显示
public bool SnapPictureAndShow(int cameraIndex)
{
	VisionImage image = new VisionImage();
	try
	{
		cameraSessionList[cameraIndex].Snap(image);
		Algorithms.Copy(image, NI_ImageViewer.Image);
		return true;
	}
	catch()
	{
		return false;
	}
}
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值