Baumer堡盟相机SDK开发示例(C#调用)
简介
工作中使用到堡盟的彩色相机,在此将调用SDK采集图像相关内容进行整理记录。
开发环境
Windows7
VS2013 64位
halcon12
之所以用到halcon,是因为获取到相机采集的图像后,需要利用halcon图像库进行处理,所以直接将图像转换为halcon库可以处理的格式。
引用库文件
在VS中创建项目,根据自己的环境引用对应的文件。
32-Bit:
\Components\Dev\C_Sharp\Win32\
bgapi2_genicam_dotnet.dll
64-Bit
\Components\Dev
bgapi2_genicam_dotnet.dll
将下列四个文件复制到项目的生产目录中
32-Bit:
\Components\Bin\Win32\目录下
bgapi2_genicam.dll
bgapi2_img.dll
bopfdrvctl.dll
MathParser.dll
64-Bit
\Components\Bin\x64\目录下
bgapi2_genicam.dll
bgapi2_img.dll
bopfdrvctl.dll
MathParser.dll
编写相机类CameraClass
public CameraClass(string id)
{
this.cameraSN = id;
}
public int connect()//连接相机函数,返回0成功返回-1失败
{
try
{
imgProcessor = BGAPI2.ImageProcessor.Instance;
if (imgProcessor.NodeList.GetNodePresent("DemosaicingMethod") == true)
{
imgProcessor.NodeList["DemosaicingMethod"].Value = "NearestNeighbor";
}
systemList = BGAPI2.SystemList.Instance;
systemList.Refresh();//刷新系统列表
if (systemList.Count == 0)
{
//没有找到系统
return -1;