Triggered Image Acquisition (dart E)#
现在大部分成像应用有用到触发图像采集。
该功能的使用#
硬件触发和软件触发#
如果相机配置为硬件触发,则施加到相机任意输入线路的电信号可以用作触发信号。
当相机配置为软件触发时,软件命令或信号将用作触发信号。可以使用 pylon API 执行软件命令。
在配置方面,硬件触发和软件触发的唯一区别在于 Trigger Source。对于硬件触发,您必须选择硬件 Trigger Source。对于软件触发,您必须选择软件 Trigger Source。
此外,某些配置步骤不适用于软件触发,例如选择 Trigger Activation 模式。
配置触发图像采集#
要配置触发图像采集:
- 将
TriggerMode
参数设置为On
以启用“触发图像采集”功能。 - 配置触发器:
- 设置
TriggerSource
参数以定义哪个信号触发触发器。 - 如果适用,请设置
TriggerActivation
参数以定义哪个信号转换触发触发器。
- 设置
信息
-
请勿以超过以下一个或两个限制因素的速率触发相机:
- 当前相机设置允许的最大帧速率。如果在相机尚未准备好接收帧开始触发信号时将其应用到相机,该信号将被忽略。
- 主机的数据传输和/或存储容量限制。如果您尝试采集的图像数量超出了主机的处理能力,则可能会丢帧。
Trigger Source#
您可以使用 TriggerSource
参数设置 Trigger Source。
此设置定义了如何激活触发。
可以使用以下触发源:
硬件 Trigger Source#
Line1
:可以通过向 I/O 线路 1 施加电信号来触发所选的触发器。PeriodicSignal1
:可以使用 Periodic Signal 功能触发所选的触发器。
软件 Trigger Source#
Software
:可以通过 pylon API 执行TriggerSoftware
命令来触发所选触发器。
触发激活模式#
您可以使用 TriggerActivation
参数设置激活模式。
此设置仅适用于硬件触发。它定义了哪个信号转换可激活所选触发。例如,您可以指定触发信号下降时将触发变为活动状态。
可以使用以下触发激活模式:
LevelHigh
:只要触发信号为高电平,触发器就处于激活状态。LevelLow
:只要触发信号为低电平,触发器就处于激活状态。
示例代码#
// Enable triggered image acquisition for the Frame Start trigger
camera.TriggerMode.SetValue(TriggerMode_On);
// Set the trigger source to Line 1
camera.TriggerSource.SetValue(TriggerSource_Line1);
// Set the trigger activation mode to level high
camera.TriggerActivation.SetValue(TriggerActivation_LevelHigh);
INodeMap& nodemap = camera.GetNodeMap();
// Enable triggered image acquisition for the Frame Start trigger
CEnumParameter(nodemap, "TriggerMode").SetValue("On");
// Set the trigger source to Line 1
CEnumParameter(nodemap, "TriggerSource").SetValue("Line1");
// Set the trigger activation mode to level high
CEnumParameter(nodemap, "TriggerActivation").SetValue("LevelHigh");
// Enable triggered image acquisition for the Frame Start trigger
camera.Parameters[PLCamera.TriggerMode].SetValue(PLCamera.TriggerMode.On);
// Set the trigger source to Line 1
camera.Parameters[PLCamera.TriggerSource].SetValue(PLCamera.TriggerSource.Line1);
// Set the trigger activation mode to level high
camera.Parameters[PLCamera.TriggerActivation].SetValue(PLCamera.TriggerActivation.LevelHigh);
/* Macro to check for errors */
#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)
GENAPIC_RESULT errRes = GENAPI_E_OK; /* Return value of pylon methods */
/* Enable triggered image acquisition for the Frame Start trigger */
errRes = PylonDeviceFeatureFromString(hdev, "TriggerMode", "On");
CHECK(errRes);
/* Set the trigger source to Line 1 */
errRes = PylonDeviceFeatureFromString(hdev, "TriggerSource", "Line1");
CHECK(errRes);
/* Set the trigger activation mode to level high */
errRes = PylonDeviceFeatureFromString(hdev, "TriggerActivation", "LevelHigh");
CHECK(errRes);
You can also use the pylon Viewer to easily set the parameters.