Reproducing Camera Conditions: Saving and Loading Basler Settings as PFS Files

Basler pylon SDK × C#

When you need to reproduce a specific capture condition or quickly switch between multiple setups, being able to save and load Basler camera settings as PFS files is extremely useful.

In this article, we’ll look at how to save and restore camera settings in .pfs format using the Basler pylon SDK.


What Is the PFS Format?

A PFS file (pylon Feature Stream file) is Basler’s configuration format for saving and loading camera settings.

✅ Typical Use Cases

  1. Backup of camera settings

    • Decide on a stable configuration once → save it → reuse it after reboot or on another PC.
  2. Sharing experiment conditions

    • Distribute settings so everyone in a lab or production line captures under the same conditions.
  3. Loading settings from your software

    • Call camera.Parameters.Load("config.pfs") to instantly apply a predefined setup (shown later).

✅ Environment

Item Value
Camera Basler acA2500-14gm
SDK Basler pylon Camera Software Suite
Language C# / .NET 8
File Format .pfs (pylon Feature Set / Feature Stream)

📝 Saving Camera Settings (Save)

As in previous articles, we’ll extend the same BaslerCameraSample class introduced in:

  • How to Display and Save Basler Camera Images with OpenCV
  • How to Capture a Single Image Using the Basler pylon SDK in C#

To save settings, we can use the Camera.Parameters.Save() method. The example below saves the CameraDevice settings. The ParameterPath argument can be either a direct string or one of the predefined properties of the ParameterPath class.

In many practical scenarios, saving just CameraDevice is sufficient. However, if you want to dump multiple parameter groups at once, you can iterate over all string properties of ParameterPath via reflection.

Even though we check Camera.Parameters.Contains(value) before calling Save(), some properties may still cause Save() to throw an ArgumentException due to model differences or unsupported paths. In that case we catch and skip them.

Note: Relying on exceptions as control flow is not ideal; if you know of a cleaner approach, feel free to adapt this logic.


📂 Example of a Saved PFS File

If you open a .pfs file in a text editor, you can see that the configuration values are stored in a tab-separated (TSV) format.

Most of the important parameters are grouped under CameraDevice, so in many cases saving just that group is enough.


📥 Loading Settings (Load)

Next, let’s load a previously saved .pfs file back into the camera.


Example: Save & Load Round Trip

The following test changes the frame rate, saves the settings, then loads them back and verifies that the value was restored.

After loading, the camera’s frame rate returns to 10 fps, confirming that the PFS file was applied correctly.


⚠️ Notes & Caveats

Point Details
What gets saved Only parameters that are exposed as user-accessible by the camera
Trigger & device-specific settings Some hardware-dependent features may be excluded
Applying PFS to another camera Prefer using the same model or a model with compatible features

✅ Summary

  • Using Camera.Parameters.Save() / Load() you can easily reproduce capture conditions.

  • .pfs files are essentially TSV-based configuration files.

  • Very useful for:

    • Backing up camera setups
    • Sharing experiment conditions
    • Managing multiple capture profiles

Coming Up Next

In the next article, we’ll look at how to log metadata such as exposure, gain, and ROI together with captured images.

I’m also working on a GUI tool to conveniently view and edit Basler camera settings; that will be introduced in a future post.


Author: @MilleVision

コメント

コメントを残す

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

CAPTCHA