pylon 會自動校正浮點數值#
當您嘗試設定不符合參數遞增值(increment)設定的浮點數值時,pylon 不會顯示錯誤訊息,而是會自動校正為最接近的可接受數值。
這適用於 Basler pylon Viewer 以及 API。
例如,a2A3840-45ucPRO 的 Exposure Time 遞增值為 9 µs。
如果您將其設定為 16 µs,您不會收到錯誤訊息,但實際的 Exposure Time 將會是 12 µs。
為什麼自動校正會選擇 12 µs 而不是 18 µs?
- 這款特定相機的最小 Exposure Time 為 12 µs。
- 由於遞增值為 9 µs,下一個可能的值為 21 µs。
- 由於目標值為 16 µs,與 21 µs 相差 5 µs,但與 12 µs 僅相差 4 µs。因此,最近鄰演算法(nearest neighbor algorithm)會選擇 12 µs 作為 Exposure Time。
透過 API 指令顯示的範例:
double val = 16;
Console.WriteLine(" trying to set value " + val);
camera.Parameters[PLCamera.ExposureTime].SetValue(val);
Console.WriteLine(" current increment " +
camera.Parameters[PLCamera.ExposureTime].GetIncrement());
Console.WriteLine("Current Exposure time is : " +
camera.Parameters[PLCamera.ExposureTime].GetValue());

當目標曝光值為 30 µs 時,不會有問題,因為這是可接受的值(12 + 2 x 9 = 30 µs)
