MilleVisionNotes

This site focuses on practical examples of controlling Basler industrial cameras
using the pylon SDK and C#, based on real-world development experience.

Overlaying a HUD on Basler Live View in WPF (FPS, Exposure, Gain) — Dual-Layer UI Layout

Overlay FPS/exposure/gain HUD on Basler live view in WPF using pylon SDK.

Once you have a working live preview, the next step is showing camera state in a readable way—especially when screen space is limited (embedded displays, lab setups, compact inspection tools).

In this article, we overlay a HUD (FPS, exposure, gain, crosshair, etc.) on top of a Basler live view in WPF. Instead of drawing text directly onto the image (which can blur or jitter during zoom/pan), we use a layer-separated approach: an image layer for the video and a transparent HUD layer that stays fixed in screen coordinates.

This structure is also a solid foundation for future features such as:

  • ROI (Region of Interest) editing in the GUI
  • Capturing and saving “image + HUD” using RenderTargetBitmap

Environment / Assumptions

  • Basler pylon Camera Software Suite (Basler.Pylon referenced)
  • .NET 8 / WPF (Windows desktop)
  • Camera: acA2500-14gm (assume Mono8)

Goal

Building on the previous live-view article, we add:

  • A two-layer layout: Video layer (Image) + HUD layer (transparent Grid)
  • The HUD is fixed to screen coordinates (does not follow zoom), so text does not blur/jitter
  • FPS calculated continuously but UI-updated at ~10 Hz, plus exposure/gain display
  • A design that can later evolve into HUD-included capture via RenderTargetBitmap

XAML: Dual Layer (with Optional ROI Layer)

Inside the display Grid, we stack multiple layers:

  • Video layer (can be zoomed/panned in future)
  • ROI layer (optional, follows the image)
  • HUD layer (screen-fixed overlay)
  • NearestNeighbor is good when you want pixel-accurate rendering.
  • Set IsHitTestVisible="False" so the HUD doesn’t steal mouse input (important for future zoom/pan).

ViewModel: Throttled FPS Updates + Exposure/Gain HUD

We extend the previous live-view ViewModel with:

  • FPS measurement using a Stopwatch
  • HUD updates throttled to ~10 Hz
  • Exposure and gain values displayed alongside FPS

Connect / Disconnect are omitted here—refer to your earlier WPF snapshot article.


Example Output

You’ll see FPS, exposure, and gain values displayed in the upper-left corner of the live preview. Live view makes FPS variations surprisingly fun to watch—feel free to customize your HUD further (movable HUD, crosshair, etc.).

HUD sample


Common Pitfalls & Fixes

  • Text looks blurry/jitters → Keep HUD on a separate layer (screen-fixed). Enable UseLayoutRounding, SnapsToDevicePixels, and ClearType settings.

  • UI is sluggish → Update video quickly; throttle HUD updates to ~10 Hz. Do heavy work (saving/analysis) on background threads.

  • Event handler registered twice → Always do -= then += in Start(), and unsubscribe in Stop() / Disconnect().


Summary

  • Implemented a dual-layer UI: image layer + HUD layer
  • HUD stays fixed in screen coordinates, making it stable during future zoom/pan
  • Displayed FPS, exposure, and gain, with FPS refreshed at ~10 Hz
  • Ready for extensions like ROI overlays and HUD-included capture with RenderTargetBitmap

コメント

コメントを残す

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

CAPTCHA