- C# 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
Standalone WPF app for creating, editing and maintaining PhAT vision jobs: Jobs, Templates, Masks, Live camera, Cameras (scan, test grab, live preview), Calibration, Vision logs, Maintenance, Messages and Log pages, plus a --screenshots self test. Builds against PhAT.Wpf at ..\PhAT.Wpf (and PhAT through it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
| Hosting | ||
| ViewModels | ||
| Views | ||
| .editorconfig | ||
| .gitignore | ||
| App.xaml | ||
| App.xaml.cs | ||
| Directory.Build.props | ||
| Directory.Build.targets | ||
| PhAT.VisionTool.csproj | ||
| PhAT.VisionTool.slnx | ||
| README.md | ||
| SelfTest.cs | ||
PhAT VisionTool
A desktop app (WPF) for creating, editing and maintaining vision jobs. It runs PhAT's own vision services, so a job edited here is the same file the web apps (MessageLog, Atlanta, Austin, ...) run, and works there unchanged. The UI comes from PhAT.Wpf.
dotnet run --project D:\Workspace\source\PhAT.VisionTool
Workspaces
The tool always works in a workspace: a folder used as the content root, like an app's folder. Every relative path resolves the way it does in the app.
| Kind | What it is | Open it with |
|---|---|---|
| Standalone | The tool's own folder: appsettings.json plus VisionJobs, VisionImages, MaskImages, TestFrames, Calibrations, VisionModels. Default Documents\PhAT VisionTool (made on first start). |
Workspace → New standalone workspace… |
| App folder | An app's folder, e.g. D:\Workspace\source\MessageLog, optionally with an instance (Instances\<name>\appsettings.json replaces appsettings.json, as with --Instance). |
Workspace → Open app folder… |
The last workspace opens at start; Workspace → Recent switches between them.
| File or folder | From | Default |
|---|---|---|
| Settings | appsettings.json, or the instance's |
— |
| Vision paths | vision-manager.json ("Vision:SettingsFile") |
— |
| Jobs | JobPath | VisionJobs/<job>.json, data in VisionJobs/<job>/ |
| Shared source images | ImagePath | VisionImages |
| Masks | "Masks:Folder" | MaskImages |
| Calibrations | "Vision:CalibrationPath" | Calibrations |
| Recorded runs | VisionLogPath | ./vision_logs |
| Run log (JSON lines) | LogPath | VisionLogs |
| Simulated camera frames | — | TestFrames |
| Model files (ALIKED, DISK, LightGlue) | — | VisionModels (the job folder first) |
Hardware
By default the tool uses simulated hardware, whatever the workspace configures:
- Camera: the TestFrames loop. Camera jobs capture its latest frame.
- Lights: every configured light becomes a simulated one, so a capture that names a light still finds it.
- Stages: the built-in simulated stages.
This way the tool never fights a running web app for the camera.
Workspace → Use the workspace's camera, lights and stages restarts the workspace with its real
Camera, Lights and Stages settings. Release or close the camera in the web app first: only
one program can have a camera open.
The Cameras page picks the camera on its own, without the lights and stages. The choice is remembered per workspace in the tool settings and wins over both modes above:
- Use selected: a camera found by the scan.
- Use simulated: the TestFrames loop.
- Use image folder…: the Files provider, which takes a folder's images in turn.
- Use workspace setting: forget the choice.
None of these change the workspace's appsettings.json. Save selected to workspace… does:
it sets Camera:Provider and Camera:Id and keeps the rest of the file (comments in it are
lost). The app opens that camera the next time it starts.
Sharing jobs with a running app
The apps reload their jobs when the job files change ("Vision": { "WatchJobs": true }, the
default). A job saved here shows up in the app's Vision page within about half a second, and
the tool picks up the app's changes the same way. Other changes need the app restarted:
- vision paths (
vision-manager.json); - calibrations;
- masks, which are read on each run anyway.
Pages
| Page | What it does |
|---|---|
| Jobs | List, filter, new, rename (also renames the data folder), duplicate (with its data), delete (the data folder is kept), reload. The job editor is the web Vision page's: ops, input, ROI (type it or draw it on the image), anchors, processing steps, op settings, templates, masks, contour browser, source, lens calibration, world coordinates, autofocus, exposure, JSON. Run runs the job as it is, unsaved changes included (logged as a manual run). Preview images only gets the images. Live preview re-runs on those images 0.4 s after each change. Ctrl+S saves, F5 runs. |
| Templates | Pick a shared image, open a file, or take a camera picture; draw a region; add processing. Save template writes the region as it is to a job's templates/. Create mask makes a mask from the region (all white, or the processed region thresholded) and opens it in the painter over the region. |
| Masks | The mask library: new blank mask, import, and the painter (brush, rectangle, white/black, invert, fill, undo/redo, zoom, the reference picture under it). Saving backs up the previous version. |
| Live camera | The live view with the published results over it. Runs a saved camera job once or repeatedly, as a sequence does: logged, and drawn on the live view. Saves a frame to the image folder or to TestFrames. |
| Cameras | Scan lists what each provider sees: Basler, The Imaging Source, Allied Vision (Vimba), FirePackage, and optionally OpenCV, which opens devices 0–9 to find them. Each provider gets its camera count or why its SDK can't be used. Test selected (or double-click) opens a camera, grabs one frame and shows it with size, pixel format, exposure and gain ranges, auto modes and a motorized lens, then closes it. It fails if another program has the camera open. Live preview streams the selected camera (with its fps) until Stop preview, no job needed and without changing the tool's camera: the camera in use is shown from the tool's live feed, any other camera is opened on its own and closed again on Stop. Picks the tool's camera (see Hardware). For the camera in use: live exposure, gain, auto modes and live fps (Apply saves camera-live.json, shared with the app), plus Release and Reconnect. |
| Calibration | Saved calibrations: details, which jobs use them, before/after undistort preview, delete. New calibration: board settings, views from files or the camera (board points drawn), calibrate (RMS and per-view error), save, and a printable board image. |
| Vision logs | Recorded runs by date, job, pass/fail and kind (automatic / manual), with each run's image, its outlines and its JSON. |
| Maintenance | Checks every job: its configuration, plus the files it needs (source images, templates, masks, model files, tessdata, calibration) and the lights its captures name. It also lists data files no setting uses. Export puts the ticked jobs in a zip, with their data folders and the shared images and masks they use. Import brings jobs in, skipping existing ones unless Replace existing is ticked. Shows the workspace's folders and edits the vision paths (vision-manager.json). |
| Messages | The app's message log, shown when the workspace has a "MessageLog" section. Read-only. |
| Log | What the workspace's services logged: camera, jobs, masks. |
The theme (System, Light, Dark) is at the top right.
Tool settings
%LocalAppData%\PhAT.VisionTool\settings.json: the theme, and the current and recent workspaces,
each with its hardware switch and the camera picked on the Cameras page.
Command line
| Argument | Meaning |
|---|---|
--workspace <folder> |
Open this folder (not remembered in the tool settings). |
--instance <name> |
With --workspace: use Instances\<name>\appsettings.json. |
--hardware |
With --workspace: the workspace's camera, lights and stages. |
--screenshots <folder> |
Self test, then quit (see below). |
Self test
PhAT.VisionTool.exe --workspace <a copy of an app folder> --screenshots <folder>
The self test goes through every page in light and dark and saves a PNG of the window for each,
plus selftest.txt with what happened. Along the way it:
- runs the job with the most ops, opens a Match shape op's contour list, and adds a processing step (live preview), then reverts it;
- loads a templates region;
- runs a camera job on the live view;
- calibrates from generated board views;
- scans the camera providers, test-grabs from an image folder (Files), checks Save to workspace on a copy of appsettings.json, and switches the tool to that folder camera to run the camera job through the camera host, then back;
- opens a vision log entry;
- checks every job;
- checks the job-folder watcher;
- exports every job, imports them into a new standalone workspace (
<folder>\selftest-standalone) and runs one there.
It writes trial-run logs into the workspace, and a temporary "Self test (camera)" job that it deletes again. Run it on a copy, not on an app's live folder.
Code
| Folder | Contents |
|---|---|
Hosting |
WorkspaceHost: PhAT's services in a Generic Host, registered as in MessageLog's Program.cs. Also ToolSettings and ToolLog. |
ViewModels |
One view model per page (CommunityToolkit.Mvvm), plus MainViewModel: the workspace and the pages. |
Views |
The window and the pages (XAML); Dialogs. |
SelfTest.cs |
--screenshots. |
Vision logic stays in PhAT: VisionJobCheck (the maintenance check) and VisionJobArchive
(export and import) are in PhAT/Vision/Jobs, next to the services the web apps use.