Baumer工业相机堡盟工业相机如何通过BGAPISDK进行定序器编程:堡盟相机双快门操作(C语言)
Baumer工业相机
Baumer工业相机堡盟相机是一种高性能、高质量的工业相机,可用于各种应用场景,如物体检测、计数和识别、运动分析和图像处理。
Baumer的万兆网相机拥有出色的图像处理性能,可以实时传输高分辨率图像。此外,该相机还具有快速数据传输、低功耗、易于集成以及高度可扩展性等特点。
Baumer RAW文件是一种记录了工业相机传感器的原始信息,同时记录了由相机拍摄所产生的一些原数据(Metadata,如ISO的设置、快门速度、光圈值、白平衡等)的文件。RAW是未经处理、也未经压缩的格式,可以把RAW概念化为“原始图像编码数据”。
Baumer GAPI SDK是由Baumer公司提供的软件开发工具包,专门为其工业相机产品定制而成。该SDK旨在为开发人员提供一系列功能强大的工具和接口,以便轻松地与Baumer的工业相机进行通信、图像采集和处理等操作。
Baumer工业相机的Camera Explorer软件功能强大,内容丰富,通过该软件可以有效的获取相机相关的全部信息,在对于相机检测项目的开发中,有时需要获取相机中图像Buffer信息和相关的数据流信息,而Camera Explorer软件可以有效的显示相关的信息。
Baumer工业相机BGAPISDK和定序器编程的技术背景
Baumer工业相机的BGAPI SDK是Baumer公司开发的针对其相机产品系列的一套软件开发工具包。该SDK提供了一组API,使开发人员可以编写专业应用程序,从而控制、捕获、处理和显示Baumer相机的图像和数据。BGAPI SDK支持多种编程语言,包括C++、C#、Visual Basic、LabVIEW、Matlab等,并提供了大量示例代码和文档,以帮助用户轻松上手,快速完成应用程序的开发。
BGAPI SDK提供了丰富的功能,可以控制Baumer相机的所有参数,包括曝光时间、增益、白平衡、触发模式等,以及支持各种数据格式,例如Raw、BMP、JPG等,同时还提供了实时显示、数据采集、图像处理等功能,为开发人员提供了高度定制化的解决方案。此外,BGAPI SDK还支持多相机系统的开发,并可支持各种计算机操作系统,如Windows、Linux、Mac OS等。
工业相机的 定序器Sequencer 功能是一种高级的编程功能,允许用户将多种拍摄参数设置成独立的序列,实现对相机的自动切换控制以满足多种不同的应用需求。使用 Sequencer 功能可以实现在一个拍摄周期内,完成多个曝光、图像传输和处理任务,从而提高工程效率和质量。
本文介绍的通过集成BGAPI SDK进行定序器编程:根据每次触发信号移动感兴趣区域的功能。
Baumer工业相机通过BGAPISDK进行定序器编程功能
下面介绍在C语言里Baumer工业相机如何通过BGAPISDK进行定序器编程:VCXG双快门操作的功能。
1.引用合适的类文件
代码如下(示例):
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "bgapi2_genicam/bgapi2_genicam.h"
2.Baumer工业相机通过BGAPISDK进行定序器编程:VCXG双快门操作功能。
本示例介绍了在C语言中如何通过硬件触发实现双快门操作的定序器编程。双快门操作旨在在很短的时间内采集2张图像。该操作使用了一种特殊的技术,让相机还在读取第一张图像的时候可以采集第二张图像。
如需了解有关定序器用途以及何时使用双快门方面的更多信息,请参阅下方的应用说明和相机《用户指南》。
下图所示为以信号曲线表示的双快门效果:在第二次曝光的最终阶段消除外界光(曝光信号中的灰色阴影区域),可确保相机实现预期动作。
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "bgapi2_genicam/bgapi2_genicam.h"
SystemList
Open a System
Get the InterfaceList and fill it Open an Interface
Get the DeviceList and fill it
Open a Device
// STOP AUQISITION AND LOAD DEFAULT PARAMETERS
printf("停止采集并加载默认参数\n");
BGAPI2_Device_GetRemoteNode(pDevice, "AcquisitionStop", &pNode);
if (BGAPI2_Node_Execute(pNode) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "UserSetSelector", &pNode);
if (BGAPI2_Node_SetString(pNode, "Default") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "UserSetLoad", &pNode);
if (BGAPI2_Node_Execute(pNode) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
// CONFIGURE HARDWARE TRIGGER INPUT
printf("配置硬件触发输入\n");
BGAPI2_Device_GetRemoteNode(pDevice, "TriggerMode", &pNode);
if (BGAPI2_Node_SetString(pNode, "On") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "TriggerSource", &pNode);
if (BGAPI2_Node_SetString(pNode, "Line0") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "TriggerActivation", &pNode);
if (BGAPI2_Node_SetString(pNode, "RisingEdge") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "TriggerDelay", &pNode);
if (BGAPI2_Node_SetDouble(pNode, 0.0) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "LineSelector", &pNode);
if (BGAPI2_Node_SetString(pNode, "Line0") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "LineInverter", &pNode);
if (BGAPI2_Node_SetBool(pNode, false) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "LineDebouncerHighTimeAbs", &pNode);
if (BGAPI2_Node_SetDouble(pNode, 1.0) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "LineDebouncerLowTimeAbs", &pNode);
if (BGAPI2_Node_SetDouble(pNode, 1.0) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
// CONFIGURE TIMER FOR FLASH
printf("为闪光灯配置定时器\n");
BGAPI2_Device_GetRemoteNode(pDevice, "TimerSelector", &pNode);
if (BGAPI2_Node_SetString(pNode, "Timer1") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "TimerTriggerSource", &pNode);
if (BGAPI2_Node_SetString(pNode, "ExposureStart") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "TimerTriggerActivation", &pNode);
if (BGAPI2_Node_SetString(pNode, "RisingEdge") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "TimerDelay", &pNode);
if (BGAPI2_Node_SetDouble(pNode, 0.0) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "TimerDuration", &pNode);
if (BGAPI2_Node_SetDouble(pNode, 100.0) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
// CONFIGURE GPIO “Line3” FOR FLASH CONTROL
printf("为闪光灯控制配置 GPIO“Line3”\n");
BGAPI2_Device_GetRemoteNode(pDevice, "LineSelector", &pNode);
if (BGAPI2_Node_SetString(pNode, "Line3") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "LineSource", &pNode);
if (BGAPI2_Node_SetString(pNode, "Timer1Active") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "LineInverter", &pNode);
if (BGAPI2_Node_SetBool(pNode, false) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
// SWITCH TO SEQUENCER CONFIG MODE
printf("切换到序列器配置模式\n");
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerConfigurationMode", &pNode);
if (BGAPI2_Node_SetString(pNode, "On") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
// SET 0 (FIRST STEP OF THE SEQUENCE)
printf("设置 0(序列的第一步)\n");
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerSetSelector", &pNode);
if (BGAPI2_Node_SetInt(pNode, 0) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerSetLoad", &pNode);
if (BGAPI2_Node_Execute(pNode) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "TriggerMode", &pNode);
if (BGAPI2_Node_SetString(pNode, "On") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "OffsetX", &pNode);
if (BGAPI2_Node_SetInt(pNode, 0) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "OffsetY", &pNode);
if (BGAPI2_Node_SetInt(pNode, 0) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "Width", &pNode);
if (BGAPI2_Node_SetInt(pNode, 320) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "Height", &pNode);
if (BGAPI2_Node_SetInt(pNode, 240) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "OffsetX", &pNode);
if (BGAPI2_Node_SetInt(pNode, 160) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "OffsetY", &pNode);
if (BGAPI2_Node_SetInt(pNode, 120) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "ExposureTime", &pNode);
if (BGAPI2_Node_SetDouble(pNode, 100.0) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerPathSelector", &pNode);
if (BGAPI2_Node_SetInt(pNode, 0) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerTriggerSource", &pNode);
if (BGAPI2_Node_SetString(pNode, "ExposureActive") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerTriggerActivation", &pNode);
if (BGAPI2_Node_SetString(pNode, "RisingEdge") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerSetNext", &pNode);
if (BGAPI2_Node_SetInt(pNode, 1) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerSetSave", &pNode);
if (BGAPI2_Node_Execute(pNode) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
// SET 1 (SECOND STEP OF THE SEQUENCE)
printf("设置 1(序列的第二步)\n");
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerSetSelector", &pNode);
if (BGAPI2_Node_SetInt(pNode, 1) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerSetLoad", &pNode);
if (BGAPI2_Node_Execute(pNode) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "TriggerMode", &pNode);
if (BGAPI2_Node_SetString(pNode, "Off") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "OffsetX", &pNode);
if (BGAPI2_Node_SetInt(pNode, 0) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "OffsetY", &pNode);
if (BGAPI2_Node_SetInt(pNode, 0) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "Width", &pNode);
if (BGAPI2_Node_SetInt(pNode, 320) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "Height", &pNode);
if (BGAPI2_Node_SetInt(pNode, 240) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "OffsetX", &pNode);
if (BGAPI2_Node_SetInt(pNode, 160) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "OffsetY", &pNode);
if (BGAPI2_Node_SetInt(pNode, 120) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
bo_double fReadOutTime_Set1 = (bo_double)pDevice->GetRemoteNode("ReadOutTime")->GetInt();
BGAPI2_Device_GetRemoteNode(pDevice, "ExposureTime", &pNode);
if (BGAPI2_Node_SetDouble(pNode, fReadOutTime_Set1) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerPathSelector", &pNode);
if (BGAPI2_Node_SetInt(pNode, 0) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerTriggerSource", &pNode);
if (BGAPI2_Node_SetString(pNode, "ExposureActive") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerTriggerActivation", &pNode);
if (BGAPI2_Node_SetString(pNode, "RisingEdge") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerSetNext", &pNode);
if (BGAPI2_Node_SetInt(pNode, 0) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerSetSave", &pNode);
if (BGAPI2_Node_Execute(pNode) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerSetStart", &pNode);
if (BGAPI2_Node_SetInt(pNode, 0) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
// SEQUENCER CONFIG END
printf("序列器配置结束\n");
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerConfigurationMode", &pNode);
if (BGAPI2_Node_SetString(pNode, "Off") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
// START CAMERA SEQUENCER
printf("启动相机序列器\n");
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerMode", &pNode);
if (BGAPI2_Node_SetString(pNode, "On") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
pDataStream->StartAcquisitionContinuous();
BGAPI2_Device_GetRemoteNode(pDevice, "AcquisitionStart", &pNode);
if (BGAPI2_Node_Execute(pNode) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
// CAPTURE IMAGES
// STOP CAMERA SEQUENCER
printf("停止相机序列器\n");
BGAPI2_Device_GetRemoteNode(pDevice, "AcquisitionStop", &pNode);
if (BGAPI2_Node_Execute(pNode) != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
pDataStream->StopAcquisition();
BGAPI2_Device_GetRemoteNode(pDevice, "SequencerMode", &pNode);
if (BGAPI2_Node_SetString(pNode, "Off") != BGAPI2_RESULT_SUCCESS) return BGAPI2_RESULT_ERROR;
return BGAPI2_RESULT_SUCCESS;
Baumer工业相机进行双快门操作的优势
双快门操作,也被称为全局快门,是一种在同一时间捕获所有素信息的方式。由于所有像素数据都是在同一时间捕获的,因此全局快门能够减少运动模糊和失真,特别是在拍摄高速运动对象时。以下是双快门操作的一些优势:
减少运动模糊:双快门操作能够在同一时间进行捕获,因此,即使在拍摄高速运动的对象时,也能够取得理想清晰的图像,而不会产生模糊现象。
减少失真:对于需要同步多相机拍摄的应用,例如三维重建,双快门操作能够减少因时间差异引起的失真。
提高图像质量:对于某些特定的应用,恶劣的光照条件下拍摄,全局快门可以减少图像噪音,提供更高的动态范围,从而提高图像质量。
更好的深度感知:在深度感知的设备上,全局快门可以提供更准确的深度信息,因为所有像素都在同一时间被捕获,这有助于准确测量物体的距离和移动速度。
总结,双快门技术使得工业相机在拍摄高速运动的对象或者在需要同步有优势,它可以减少模糊和失真,提高图像质量,以及提供更准确的深度信息。
Baumer工业相机进行双快门操作的行业应用
双快门操作,也被称为全局快门,是一种在同一时间捕获所有素信息的方式。由于所有像素数据都是在同一时间捕获的,因此全局快门能够减少运动模糊和失真,特别是在拍摄高速运动对象时。以下是双快门操作的一些优势:
减少运动模糊:双快门操作能够在同一时间进行捕获,因此,即使在拍摄高速运动的对象时,也能够取得理想清晰的图像,而不会产生模糊现象。
减少失真:对于需要同步多相机拍摄的应用,例如三维重建,双快门操作能够减少因时间差异引起的失真。
提高图像质量:对于某些特定的应用,恶劣的光照条件下拍摄,全局快门可以减少图像噪音,提供更高的动态范围,从而提高图像质量。
更好的深度感知:在深度感知的设备上,全局快门可以提供更准确的深度信息,因为所有像素都在同一时间被捕获,这有助于准确测量物体的距离和移动速度。
总结,双快门技术使得工业相机在拍摄高速运动的对象或者在需要同步有优势,它可以减少模糊和失真,提高图像质量,以及提供更准确的深度信息。