TDI (Time Delay Integration)#
TDI 可提高光感度並產生動態範圍更寬的較亮影像,非常適合用於微光環境。
資訊
此功能僅適用於 Basler racer 2 XL 與 racer 2 L mono 相機。
使用此功能#
此功能的實作方式會因相機而異:
racer 2 XL 相機#
racer 2 XL 相機配備了 TDI 感光元件。TDI 感光元件由多行像素組成,稱為級 (stages),並排列成陣列 (array)。
當物體穿過感光元件的視場時,其影像會從第一級的曝光區域投影到最後一級的曝光區域。各級不是逐一單獨曝光,而是作為一個整體區塊進行曝光。因此,感光元件會在每個級對同一物體進行曝光,並累積和傳輸電荷,直到它們到達讀取線。
下圖展示了四級感光元件內的電荷傳輸。
從一級到下一級的電荷傳輸必須與物體的運動保持精確同步。這可確保連續曝光和電荷整合。物體的曝光時間與其在相機視場中的停留時間相同。使用的級數越多,有效 Exposure Time 與整合時間就越長。
下圖顯示了 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:通過感測器視野的物件會以 reverse 掃描方向。它會先通過相機的頂部,然後通過底部。
Resulting Exposure Time#
在 TDI 感測器擷取模式中,Exposure Time 不是透過 ExposureTime Property 來設定。相反地,它是由以下兩個擷取參數所決定:
- Number of stages:定義物件在累積和轉移電荷時,停留在感測器視野中的時間長度。
- Line rate:定義電荷從一個階段轉移到下一個階段的速度。它也決定了每個個別階段的積分時間。
這兩個參數共同決定了總體 Exposure Time:
$$ \text{Exposure time} = \frac{\text{Number of stages}}{\text{Line rate}} $$
下表顯示在固定 Line rate 500 kHz 以及不同 Number of stages 下的範例 Exposure Time:
| Number of Stages | Line Rate [kHz] | Exposure Time [µs] |
|---|---|---|
| 4 | 500 | 8 |
| 64 | 500 | 128 |
| 128 | 500 | 256 |
| 256 | 500 | 512 |
下表顯示在固定 128 個階段以及高達 500 kHz 最大 Line rate 的不同 Line rate 下的範例 Exposure Time:
| Line Rate [kHz] | Number of Stages | Exposure Time [µs] |
|---|---|---|
| 100 | 128 | 1280 |
| 200 | 128 | 640 |
| 400 | 128 | 320 |
| 500 | 128 | 256 |
由於 Number of stages 和 Line rate 都會影響 Exposure Time,因此它們也會影響影像亮度,前提是觸發已與物件的移動正確同步,且符合像素飽和度極限:
- 較高的 Number of stages 會增加 Exposure Time,因此會導致累積更多電荷。影像將會顯得更亮。
- 較低的 Number of stages 會減少 Exposure Time,因此會導致累積較少電荷。影像將會顯得更暗。
- 較高的 Line rate 會減少每個階段的 Exposure Time,因此會導致累積較少電荷。影像將會顯得更暗。
- 較低的 Line rate 會增加每個階段的 Exposure Time,因此會導致累積更多電荷。影像將會顯得更亮。
為 TDI 配置 racer 2 XL 相機#
若要將 racer 2 XL 相機設定為 TDI 模式:
- 將
BslSensorAcquisitionMode參數設為TDISingleLine。此感測器使用一條讀取線。 - 根據您的系統設置,將
BslTDIScanDirection參數設為(例如)Forward. - 將
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#
Line combination mode 允許您定義是將組合感測器行的像素值相加還是求平均值。您可以將 BslLineCombinationMode 參數設為下列其中一個值:
Off: Line combination 已停用。TDISum: 組合感測器行的像素值會相加。這會增加相機對光的響應以及訊噪比。TDIAverage: 組合感測器行的像素值會取平均值。這會增加訊噪比,且不會影響相機對光的響應。
為 TDI 配置 racer 2 L Mono 相機#
若要為 TDI 設定 racer 2 L 單色相機:
- 將 感測器擷取模式 設為雙行或四行影像擷取:
將BslSensorAcquisitionMode參數設為DualLine或QuadLine取決於您是要將兩行還是四行用於 TDI。 -
指定每一行(級數)的 Exposure Time:
- 將
ExposureTimeMode參數設為Individual. - 將
ExposureTimeSelector參數設為Stage1. - 將
ExposureTime參數設定為所需的微秒曝光時間。
注意: 您可以在以下位置找到相機型號的最小和最大 Exposure Time 值: 詳細資料 部分,位於 Exposure Time 主題。 - 對其他級數重複步驟 b 和 c。
- 將
-
指定 spatial correction stride 以決定 Spatial Correction 的起始行與方向:
將BslSpatialCorrectionStride參數設為(例如)2。 - 將 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);
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 來輕鬆設定參數。