Repository navigation
Architecture and Processing Pipeline
FishTrack separates its PySide6 desktop interface from the underlying video-processing engine. The same engine can be called from the command line, keeping interface-specific behaviour out of the core algorithms. This page describes the responsibilities and control flow; detailed algorithm behaviour is covered in Finding Fish and Tracking Fish.
| Component | Responsibility |
|---|---|
| GUI (PySide6) | Browse files; select the processing interval and options; display preview, progress and logs; host selection/review dialogs. |
| Acquisition | Obtain starting ROIs by manual selection or first-frame Grounding DINO proposals; optionally discover motion candidates using Conventional CV. |
| Tracking backend | Maintain IDs and process successive frames using Conventional CV (motion and appearance) or the SAM 2 video predictor. |
| Annotation | Draw selected outlines, rectangles and IDs on output frames and previews. |
| Export | Encode a temporary MP4, validate it by decoding and publish only a completed output. |
| Diagnostics | Optionally write proposal records, motion diagnostics or segmentation-mask statistics, as well as operational logs. |
The acquisition and tracking stages are not interchangeable. Grounding DINO proposes regions on the first processed frame but does not track. Conventional CV's independent motion acquisition can run later in the clip and can add tracks when enabled. SAM 2, by contrast, needs an accepted starting region for each object it follows.
- Validate the run. Check the input MP4, output path, requested interval, and backend-specific options.
- Prepare the starting frame. Decode the first processed frame and obtain starting ROIs by manual selection or Grounding DINO, if requested. Grounding DINO runs only at this stage.
- Review selections. Present suggested regions for correction or accept them automatically when explicitly configured. Conventional CV may instead start with motion-based acquisition.
- Track and, where enabled, acquire more objects. Process subsequent frames with Conventional CV or SAM 2, maintaining IDs and backend state within the run. Conventional CV may discover additional motion candidates during processing; this does not invoke Grounding DINO again.
- Annotate and diagnose. Draw frames for preview and output, and record optional diagnostic information.
- Publish safely. Finish the temporary MP4, verify that it can be decoded and publish it only on success. On cancellation or failure, do not publish an incomplete output video.
See Process a Video with FishTrack for the user-facing version of these steps.
The GUI handles user interaction while processing runs in a worker thread, allowing the application to remain responsive. Callbacks carry progress, frame previews, processing messages and cancellation requests between the engine and interface.
Cancellation is cooperative: an inference operation already underway may finish before the worker stops. Closing the window during processing requests cancellation and waits for a safe stop. This separation also allows the command-line entry point to use the processing engine without the desktop interface.
Conventional CV estimates camera motion, finds residual movement and can associate newly observed moving candidates with tracks. It can also follow selected or acquired regions by appearance. Its motion thresholds, camera-alignment controls and missing-track allowances apply to this backend only.
SAM 2 uses accepted starting ROIs to initialise its video predictor and generates masks through a bounded interval. It does not use the conventional camera-aligned motion masks or CSRT parameters. Its own model, device and minimum-mask-area settings apply to SAM 2 rather than Conventional CV.
These boundaries are important when comparing runs: the same starting selections can be supplied to either tracker, but backend-specific settings are not equivalent. See Tracking Fish and Settings and Configuration.
Packaged desktop defaults are maintained separately from saved preferences. Preferences and logs are stored in OS-standard Qt application locations. Diagnostic outputs, when requested, belong to the processing run and differ by backend: proposal JSON/JPG for Grounding DINO, motion masks and statistics for Conventional CV, and masks and per-object statistics for SAM 2.
The main exported file is an annotated, video-only MP4. The temporary-output and validation stages protect the original recording and avoid publishing incomplete results. See Diagnostics and Troubleshooting for diagnostic filenames, log locations and output details.