跳转到内容
STAGING SERVER
DEVELOPMENT SERVER

TDI (Time Delay Integration)#

TDI (Time Delay Integration) 是一种用于线扫描相机的成像技术,它可以通过分步采集图像数据来补偿物体的运动。

TDI 能够提高光敏度,生成更亮、动态范围更广的图像,这使其成为低光照条件下的理想选择。

信息

此功能仅适用于 Basler racer 2 XL 和 racer 2 L mono 相机。

该功能的使用#

此功能具体取决于不同的相机型号:

racer 2 XL 相机#

racer 2 XL 相机配备了 TDI 传感器。TDI 传感器由多行像素(称为级(stages))组成,它们排列成一个阵列。

当物体穿过传感器的视场时,其图像会从第一级的曝光区投影到最后一级的曝光区。各个级不是逐级单独曝光的,而是作为一个整体块进行曝光。因此,传感器会在每个级对同一个物体进行曝光,并累积和传输电荷,直到它们到达读出线。

下图展示了四级传感器内部的电荷传输过程。

TDI 传感器电荷传输

从一级到下一级的电荷传输必须与物体的运动保持精确同步。这可确保连续曝光和电荷积分。物体的曝光持续时间取决于它在相机视场中的停留时间。使用的级数越多,有效的 Exposure Time 和积分时间就越长。

下图显示了 TDI 传感器的视场及其电荷转移原理:

TDI 相机电荷转移原理

Number Of Stages#

级数决定了电荷从一级累积并转移到下一级直至到达最后一级的频率。级数越高,图像灵敏度越高。例如,如果级数设置为 256,则相机采集图像的灵敏度将提高 256 倍。级数也会影响最终的 Exposure Time。

可以将传感器设置为使用不同的级数,例如 4 级或最多 256 级。可用的级数取决于所使用的传感器。

若要设置级数,请将 BslTDINumberOfStages 参数值设置为(例如) Stages4 或 Stages256.

信息

在 Area sensor acquisition mode 中,级数决定了图像高度。例如,当级数设置为 128 时,r2T16416-500cm 相机将在 Area sensor acquisition mode 中采集 16416 x 128 的“面阵”图像。

Scan Direction#

TDI 传感器的扫描方向必须与穿过相机的物体的运动保持同步。扫描方向必须与物体的移动方向相同,以确保连续曝光和电荷积分。

信息

关于如何设置扫描方向的说明假设您在相机上使用了镜头。镜头会使图像倒置。

若要设置扫描方向,请将 BslTDIScanDirection 参数设置为以下值:

  • Forward:穿过传感器视场的物体将以 正向 扫描方向进行扫描。它首先穿过相机的底部,然后穿过顶部。
  • Reverse:穿过传感器视场的物体将以 反向 扫描方向。它首先穿过相机的顶部,然后穿过底部。

Resulting Exposure Time#

在 TDI 传感器采集模式 模式下,Exposure Time 的设置并非通过 ExposureTime 参数进行。相反,它由以下两个采集参数共同决定:

  • Number of stages:定义物体在传感器的视野中停留的时间,在此期间电荷会不断累积和转移。
  • Line rate:定义电荷从一个级转移到下一个级的速度。它还决定了各个级单独的积分时间。

这两个参数共同决定了总的 Exposure Time:

$$ \text{Exposure time} = \frac{\text{Number of stages}}{\text{Line rate}} $$

下表显示了在 500 kHz 的固定 Line Rate 以及不同级数下的示例 Exposure Time:

级数 Line Rate [kHz] Exposure Time [µs]
4 500 8
64 500 128
128 500 256
256 500 512

下表显示了在固定 128 级以及最高达 500 kHz 的不同 Line Rate 下的示例 Exposure Time:

Line Rate [kHz] 级数 Exposure Time [µs]
100 128 1280
200 128 640
400 128 320
500 128 256

由于级数和 Line rate 都会影响 Exposure Time,因此它们也会影响图像亮度,前提是触发与物体的运动正确同步,并且没有超过像素饱和度极限:

  • 较高的级数会增加 Exposure Time,从而导致更多的电荷累积。图像会显得更亮。
  • 较低的级数会减少 Exposure Time,从而导致更少的电荷累积。图像会显得更暗。
  • 较高的 Line rate 会减少每级的 Exposure Time,从而导致更少的电荷累积。图像会显得更暗。
  • 较低的 Line rate 会增加每级的 Exposure Time,从而导致更多的电荷累积。图像会显得更亮。

为 TDI 配置 racer 2 XL 相机#

若要将 racer 2 XL 相机配置为 TDI 模式:

  1. 设置 BslSensorAcquisitionMode acquisition mode TDISingleLine。传感器使用一条读出线。
  2. 根据您的系统设置,将 BslTDIScanDirection 参数设置为(例如) Forward.
  3. 设置 BslTDINumberOfStages 参数设置为(例如)128。

信息

  • 确保传感器的读出过程与物体运动的速度和方向完全同步。出于测试目的,请相应地更改 acquisition line rate。这也会影响最终的 exposure time。
  • 在触发暂停后重新触发时,至少必须将前 n 个读出线视为无效,其中 n 表示最小级数。

racer 2 L Mono 相机#

racer 2 L mono cameras 配备了多行传感器,即双线或四线传感器。传感器中的每一条像素线都可以设置为使用不同的 Exposure Time 进行曝光。每当触发采集时,传感器的所有像素线都会同时曝光。对于单次曝光,传感器中的每一线都会在物体上采集不同的区域,因为对于任何经过相机的物体,每一线都有不同的视场。

以下图示展示了单色四线传感器的视场。

单色四线传感器的视场

在这种情况下,必须对来自四次不同采集的数据进行缓冲和组合,以获取物体上某个区域的完整信息。这可以通过 Spatial Correction 来完成。当前曝光最后一线的数据与以往曝光中获取的前几线的数据相结合。

使用 Line Combination Mode,您可以最终指定组合各个线像素值的方式,以获得 HDR 图像。

Line Combination Mode#

线组合模式允许您定义组合后的传感器线像素值是相加还是取平均值。您可以设置 BslLineCombinationMode 参数设置为以下值:

  • Off:禁用线组合。
  • TDISum:组合后的传感器线像素值相加。这会增加相机的光响应和信噪比。
  • TDIAverage:组合后的传感器线像素值取平均值。这会在不影响相机光响应的情况下提高信噪比。

为 TDI 配置 racer 2 L Mono 相机#

若要将 racer 2 L 黑白相机配置为 TDI 模式:

  1. 设置 传感器采集模式 设为双线或四线图像采集:
    设置 BslSensorAcquisitionMode acquisition mode DualLine 或 QuadLine 具体取决于您希望使用两线还是四线进行 TDI。
  2. 为每一线(级)指定 Exposure Time:

    1. 设置 ExposureTimeMode acquisition mode Individual.
    2. 设置 ExposureTimeSelector acquisition mode Stage1.
    3. 设置 ExposureTime 参数设置为所需的微秒级 Exposure Time。
      注意: 您可以在相机型号的 详情 章节中找到 Exposure Time 主题中找到有关突发图像采集的更多信息。
    4. 对其他各级重复步骤 b 和 c。
  3. 指定 spatial correction stride 以确定 Spatial Correction 的起始线和方向:
    设置 BslSpatialCorrectionStride 参数设为(例如)2。

  4. 设置 line combination mode 以确定组合线的传感器像素值是相加还是取平均值:
    设置 BslLineCombinationMode 参数设置为(例如) TDIAverage.

使用外部后处理程序组合线信息以生成高动态范围图像。

示例代码#

racer 2 XL 相机#
// Set the sensor acquisition mode to TDI Single Line
camera.BslSensorAcquisitionMode.SetValue(BslSensorAcquisitionMode_TDISingleLine);
// Set the sensor scan direction to Forward
camera.BslTDIScanDirection.SetValue(BslTDIScanDirection_Forward);
// Set the number of stages to 128
camera.BslTDINumberOfStages.SetValue(BslTDINumberOfStages_128);
INodeMap& nodemap = camera.GetNodeMap();
// Set the sensor acquisition mode to TDI Single Line
CEnumParameter(nodemap, "BslSensorAcquisitionMode").SetValue("TDISingleLine");
// Set the sensor scan direction to Forward
CEnumParameter(nodemap, "BslTDIScanDirection").SetValue("Forward");
// Set the number of stages to 128
CEnumParameter(nodemap, "BslTDINumberOfStages").SetValue("");
// Set the sensor acquisition mode to TDI Single Line
camera.Parameters[PLCamera.BslSensorAcquisitionMode].SetValue(PLCamera.BslSensorAcquisitionMode.TDISingleLine);
// Set the sensor scan direction to Forward
camera.Parameters[PLCamera.BslTDIScanDirection].SetValue(PLCamera.BslTDIScanDirection.Forward);
// Set the number of stages to 128
camera.Parameters[PLCamera.BslTDINumberOfStages].SetValue(PLCamera.BslTDINumberOfStages.);
/* 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 */
/* Set the sensor acquisition mode to TDI Single Line */
errRes = PylonDeviceFeatureFromString(hdev, "BslSensorAcquisitionMode", "TDISingleLine");
CHECK(errRes);
/* Set the sensor scan direction to Forward */
errRes = PylonDeviceFeatureFromString(hdev, "BslTDIScanDirection", "Forward");
CHECK(errRes);
/* Set the number of stages to 128 */
errRes = PylonDeviceFeatureFromString(hdev, "BslTDINumberOfStages", "");
CHECK(errRes);
# Set the sensor acquisition mode to TDI Single Line
camera.BslSensorAcquisitionMode.Value = "TDISingleLine"
# Set the sensor scan direction to Forward
camera.BslTDIScanDirection.Value = "Forward"
# Set the number of stages to 128
camera.BslTDINumberOfStages.Value = ""
racer 2 L Mono 相机#
// Set the sensor acquisition mode to Dual Line
camera.BslSensorAcquisitionMode.SetValue(BslSensorAcquisitionMode_DualLine);
// Set the exposure time for both lines (stages)
// Select stage 1
camera.ExposureTimeSelector.SetValue(ExposureTimeSelector_Stage1);
// Set the exposure time to 1000 microseconds
camera.ExposureTime.SetValue(1000.0);
// Select stage 2
camera.ExposureTimeSelector.SetValue(ExposureTimeSelector_Stage2);
// Set the exposure time to 1000000 microseconds
camera.ExposureTime.SetValue(1000000.0);
// Set the spatial correction stride to 2
camera.BslSpatialCorrectionStride.SetValue(BslSpatialCorrectionStride_2);
// Set the line combination mode to TDI Sum
camera.BslLineCombinationMode.SetValue(BslLineCombinationMode_TDISum);
INodeMap& nodemap = camera.GetNodeMap();
// Set the sensor acquisition mode to Dual Line
CEnumParameter(nodemap, "BslSensorAcquisitionMode").SetValue("DualLine");
// Set the exposure time for both lines (stages)
// Select stage 1
CEnumParameter(nodemap, "ExposureTimeSelector").SetValue("Stage1");
// Set the exposure time to 1000 microseconds
CFloatParameter(nodemap, "ExposureTime").SetValue(1000.0);
// Select stage 2
CEnumParameter(nodemap, "ExposureTimeSelector").SetValue("Stage2");
// Set the exposure time to 1000000 microseconds
CFloatParameter(nodemap, "ExposureTime").SetValue(1000000.0);
// Set the spatial correction stride to 2
CEnumParameter(nodemap, "BslSpatialCorrectionStride").SetValue("");
// Set the line combination mode to TDI Sum
CEnumParameter(nodemap, "BslLineCombinationMode").SetValue("TDISum");
// Set the sensor acquisition mode to Dual Line
camera.Parameters[PLCamera.BslSensorAcquisitionMode].SetValue(PLCamera.BslSensorAcquisitionMode.DualLine);
// Set the exposure time for both lines (stages)
// Select stage 1
camera.Parameters[PLCamera.ExposureTimeSelector].SetValue(PLCamera.ExposureTimeSelector.Stage1);
// Set the exposure time to 1000 microseconds
camera.Parameters[PLCamera.ExposureTime].SetValue(1000.0);
// Select stage 2
camera.Parameters[PLCamera.ExposureTimeSelector].SetValue(PLCamera.ExposureTimeSelector.Stage2);
// Set the exposure time to 1000000 microseconds
camera.Parameters[PLCamera.ExposureTime].SetValue(1000000.0);
// Set the spatial correction stride to 2
camera.Parameters[PLCamera.BslSpatialCorrectionStride].SetValue(PLCamera.BslSpatialCorrectionStride.);
// Set the line combination mode to TDI Sum
camera.Parameters[PLCamera.BslLineCombinationMode].SetValue(PLCamera.BslLineCombinationMode.TDISum);
/* 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 */
/* Set the sensor acquisition mode to Dual Line */
errRes = PylonDeviceFeatureFromString(hdev, "BslSensorAcquisitionMode", "DualLine");
CHECK(errRes);
/* Set the exposure time for both lines (stages) */
/* Select stage 1 */
errRes = PylonDeviceFeatureFromString(hdev, "ExposureTimeSelector", "Stage1");
CHECK(errRes);
/* Set the exposure time to 1000 microseconds */
errRes = PylonDeviceSetFloatFeature(hdev, "ExposureTime", 1000.0);
CHECK(errRes);
/* Select stage 2 */
errRes = PylonDeviceFeatureFromString(hdev, "ExposureTimeSelector", "Stage2");
CHECK(errRes);
/* Set the exposure time to 1000000 microseconds */
errRes = PylonDeviceSetFloatFeature(hdev, "ExposureTime", 1000000.0);
CHECK(errRes);
/* Set the spatial correction stride to 2 */
errRes = PylonDeviceFeatureFromString(hdev, "BslSpatialCorrectionStride", "");
CHECK(errRes);
/* Set the line combination mode to TDI Sum */
errRes = PylonDeviceFeatureFromString(hdev, "BslLineCombinationMode", "TDISum");
CHECK(errRes);
# Set the sensor acquisition mode to Dual Line
camera.BslSensorAcquisitionMode.Value = "DualLine"
# Set the exposure time for both lines (stages)
# Select stage 1
camera.ExposureTimeSelector.Value = "Stage1"
# Set the exposure time to 1000 microseconds
camera.ExposureTime.Value = 1000.0
# Select stage 2
camera.ExposureTimeSelector.Value = "Stage2"
# Set the exposure time to 1000000 microseconds
camera.ExposureTime.Value = 1000000.0
# Set the spatial correction stride to 2
camera.BslSpatialCorrectionStride.Value = ""
# Set the line combination mode to TDI Sum
camera.BslLineCombinationMode.Value = "TDISum"

您也可以使用 pylon Viewer 轻松设置参数。