How to Manually Control Exposure Time Using the Basler pylon SDK (C# / .NET 8)


How to Manually Control Exposure Time Using the Basler pylon SDK (C# / .NET 8)

Have you ever felt that your industrial camera images look too dark, too bright, or fluctuate unexpectedly?
Automatic exposure (auto-exposure) can be useful, but in many machine-vision or inspection systems, consistent lighting is essential, and automatic adjustments can cause instability.

With the Basler pylon SDK, you can switch exposure control to manual mode and specify an exact exposure time (in microseconds), enabling stable and predictable imaging.

This article explains how to set, read, and validate exposure time manually using C# and the pylon SDK.


✔ Environment

ItemDetails
CameraBasler acA2500-14gm
SDKBasler pylon Camera Software Suite
LangC# / .NET 8.0 (Windows)

💡 Background: GenICam and Camera Parameters

Parameters such as ExposureTimeAbs used in this article follow GenICam (Generic Interface for Cameras) — an industry standard used by Basler, FLIR, IDS, JAI, and many other industrial camera manufacturers.

With GenICam SFNC (Standard Features Naming Convention), you can access:

  • Exposure
  • Gain
  • ROI / image size
  • Trigger settings
  • Acquisition modes

all using a common parameter model.

👉 GenICam SFNC specification:
https://www.emva.org/standards-technology/genicam/

This article focuses on practical usage, but knowing that pylon follows GenICam helps when switching between camera brands.


🔧 Setting Exposure Time Manually

Below is an extension to the BaslerCameraSample class from the previous article.

Method: Set Exposure Time (manual mode)


Helper Functions

Set auto-exposure mode (Off / Once / Continuous)

Set an enum parameter

Set a floating-point parameter (e.g., ExposureTimeAbs)


🔍 Reading the Current Exposure Time

Use GetValue() to read exposure parameters from the camera.


💡 About ExposureAuto Modes

ValueBehavior
OffManual exposure (used in this article)
OnceAdjusts exposure once, then fixes it
ContinuousContinuously adjusts to maintain brightness

📷 Example: Change Exposure and Capture Images

The test below captures images at 5 ms, 20 ms, and 50 ms.


📊 Exposure Comparison


5 ms (darker) 20 ms (balanced) 50 ms (brighter)
5ms 20ms 50ms

🧭 Common Issues & Troubleshooting

IssueCause / Solution
Exposure does not changeExposureAuto is still On
Value outside valid rangeExposure too long or too short for the camera model
Image too dark/brightLighting or gain settings are insufficient
Exposure fluctuatesExternal lighting or auto exposure still enabled

📝 Summary

  • Set ExposureAuto = Off to enable manual exposure control
  • Exposure time is specified in microseconds (μs)
  • pylon SDK accesses all parameters through Camera.Parameters[...], following GenICam SFNC

🔜 Coming Up Next

Exposure alone may not give enough brightness range depending on your lighting environment.
The next article will cover manual gain control using the pylon SDK.

コメント

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA