TDI (延時積分)#
TDI 可提高感光度,並呈現更明亮且動態範圍更廣的影像,因此非常適合在低光環境下使用。
資訊
此功能僅適用於 Basler racer 2 XL 以及racer 2 L 單色相機上提供。
使用功能#
此功能的實作方式會因相機而異:
racer 2 XL 相機#
racer 2 XL 相機配備了TDI 感光元件。TDI 感光元件由多行像素(稱為「階段」)組成,這些像素以陣列形式排列。
當物體穿過感光元件的視野時,其影像會從第一級的曝光區域投射至最後一級的曝光區域。各級並非逐級分別進行曝光,而是以整個區塊的形式進行曝光。因此,感光元件在每一級都會對同一物體進行曝光,並持續累積與傳輸電荷,直至電荷抵達讀出線為止。
下圖直觀地展示了四級感測器內的電荷傳輸過程。
從一個平台到下一個平台的電荷轉移,必須與物體的移動完全同步。這能確保持續的曝光與電荷積分。物體的曝光時間,取決於其處於相機視野內的時間長短。使用的平台越多,有效的曝光時間與積分時間就越長。
下圖顯示了TDI 感測器的視野及其電荷移位原理:
階段數#
級數決定了電荷被累積並從一個級數傳遞到下一個級數的頻率,直至到達最後一個級數為止。級數越高,影像靈敏度就越高。例如,若級數為 256,相機所拍攝的影像靈敏度將提高 256 倍。級數也會影響最終的曝光時間。
該感測器可設定為支援不同數量的階段,例如 4 個階段或多達 256 個階段。可用的階段數量取決於所使用的感測器。
要設定階段數,請設定 BslTDINumberOfStages 將參數值設定為,例如: Stages4 或 Stages256.
資訊
在「區域感測器」擷取模式下,階段數決定了影像的高度。例如,當階段數設定為 128 時,r2T16416-500cm相機將在「區域感測器」擷取模式下擷取 16416 × 128 的「區域」影像。
掃描方向#
TDI 感測器的掃描方向必須與經過相機的物體移動方向保持同步。掃描方向必須與物體的移動方向一致,以確保曝光與電荷積分的連續性。
資訊
關於如何設定掃描方向的說明,是假設您在相機上安裝了鏡頭。鏡頭會將影像倒置。
要設定掃描方向,請設定 BslTDIScanDirection 參數設定為以下值之一:
Forward: 經過感測器視野的物體會在 正向 掃描方向。它會先經過相機底部,然後再經過頂部。Reverse: 經過感測器視野的物體會在 反向 掃描方向。它先經過相機的頂部,然後經過底部。
由此產生的Exposure Time#
在TDI 感測器擷取模式,曝光時間並非透過 ExposureTime 參數。相反地,它是由兩個擷取參數所決定的:
這兩個參數共同決定了總曝光時間:
$$ \text{曝光時間} = \frac{\text{階段數}}{\text{線速}} $$
下表列出了在固定線路速率為 500 kHz 且各階段數量不同的情況下,曝光時間的範例:
| 階段數 | 線速 [kHz] | Exposure Time [µs] |
|---|---|---|
| 4 | 500 | 8 |
| 64 | 500 | 128 |
| 128 | 500 | 256 |
| 256 | 500 | 512 |
下表列出了在固定為 128 級的情況下,以及不同行速(最高達 500 kHz)時的曝光時間範例:
| 線速 [kHz] | 階段數 | Exposure Time [µs] |
|---|---|---|
| 100 | 128 | 1280 |
| 200 | 128 | 640 |
| 400 | 128 | 320 |
| 500 | 128 | 256 |
由於階段數和線速都會影響曝光時間,因此它們也會影響影像亮度——前提是觸發時機已與物體的運動正確同步,且符合像素飽和度限制:
- 曝光階段數越多,曝光時間就越長,因此累積的電荷也會越多。影像會顯得更明亮。
- 曝光階段數越少,曝光時間就越短,因此累積的電荷也越少。影像會顯得較暗。
- 較高的線速會縮短每個階段的曝光時間,從而導致累積電荷減少。影像會顯得較暗。
- 較低的線速會增加每個階段的曝光時間,從而導致累積電荷更多。影像會顯得更明亮。
設定racer 2 XL 攝影機以用於TDI#
若要將racer 2 XL 攝影機設定為支援TDI ,請依下列步驟操作:
- 將相機中的
BslSensorAcquisitionMode參數設為TDISingleLine. 該感測器使用一條讀出線。 - 請根據您的系統設定,將
BslTDIScanDirection將參數設定為,例如:Forward. - 將相機中的
BslTDINumberOfStages將參數設定為,例如 128。
資訊
racer 2 L 單鏡頭相機#
racer 2 L 單色相機配備多線感測器,即雙線或四線感測器。感測器的每條像素線均可設定為使用不同的曝光時間進行曝光。每當觸發影像擷取時,感測器上的所有像素線會同時進行曝光。在單次曝光過程中,由於感測器中的每條線對經過相機的任何物體皆具有不同的視野範圍,因此感測器中的每條線會擷取物體上的不同區域。
下圖顯示了一款單色四線式線性感測器的視野範圍。
在此情況下,必須將來自四次不同採集的資料進行緩衝處理並合併,才能獲得物體上某個區域的完整資訊。這透過空間校正來實現。當前曝光的最後一行資料,會與先前曝光所取得的先前幾行的資料進行合併。
透過「線組合模式」,您終於可以指定應如何組合各條線的像素值,以生成您的 HDR 影像。
行組合模式#
「線組合模式」可讓您定義組合後的感測器線之像素值應採求和或求平均的方式計算。您可以設定 BslLineCombinationMode 參數設定為以下值之一:
Off: 行組合功能已停用。TDISum: 合併後的感測器列的像素值會被相加。此舉可提升相機對光線的靈敏度,並提高訊號雜訊比。TDIAverage: 將合併後的感測器行之像素值進行平均。此舉可提高訊號雜訊比,同時不影響相機對光線的反應。
設定racer 2 L 單鏡頭攝影機以用於TDI#
要將racer 2 L 單鏡頭攝影機設定為TDI 模式,請依以下步驟操作:
- 將相機中的 感測器擷取模式 關於雙線或四線影像擷取:
將相機中的BslSensorAcquisitionMode參數設為DualLine或QuadLine這取決於您想為 `TDI` 使用兩行還是四行。 -
請指定每行(階段)的曝光時間:
- 將相機中的
ExposureTimeMode參數設為Individual. - 將相機中的
ExposureTimeSelector參數設為Stage1. - 將相機中的
ExposureTime將此參數設定為所需的曝光時間(單位為微秒)。
註: 您可以在 詳細資料 一節中所解釋的 Exposure Time 主題。 - 針對其餘階段,請重複步驟 b 和 c。
- 將相機中的
-
請指定 空間校正步長 以確定空間校正的起點與方向:
將相機中的BslSpatialCorrectionStride將參數設定為,例如 2。 - 將相機中的 行組合模式 以確定合併線的感測器像素值是進行求和還是求平均:
將相機中的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 單鏡頭相機#
// 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"
您也可以 use the pylon Viewer 來輕鬆設定參數。