White particles scattered on black; around two counter-rotating vortices, arrows coloured by speed. The band flowing down between them is the fastest.
Products

Measure the flow as you film,
with the corrections experiments need.

An app and library that measure flow fields from a camera, live on an iPad, by PIV and PTV. It removes the glass reflections, glare and glints, undoes the lens effect of the filled container by ray tracing, and reports velocity fields in true plane coordinates. Every vector comes with its uncertainty.

Source code (.zip) Documents

Free and open source (MIT). iPadOS 17, macOS 14. The iPad app is built with Xcode (a free Apple ID works).1

Behind: particle images from LivePTV’s synthetic source (a counter-rotating vortex pair) through its analysis pipeline, with the vectors of PIV at ½ resolution drawn over them.6

LivePTV

This is LivePTV

Real-time PIV and PTV on an iPad,
with the corrections a real experiment needs.

A camera looks at a bottle or a tank. LivePTV removes the glass reflections, glare and glints, undoes the lens effect of the filled container by ray tracing, and reports velocity fields in true plane coordinates. Every vector comes with its uncertainty, and a methods paragraph is generated for your paper.

  1. Analysed
    as you film.

    Image deformation and the 32-px correlation run on the GPU (Metal). A USB camera’s 1920 × 1080 stream at 30 fps, on an Apple M4 Mac, was analysed as it streamed: PIV at ½ resolution, 29 frames per second.

  2. Through the bottle,
    in true coordinates.

    Reflections, labels and scratches go with the running-mean background; glare and glints on the surface are masked. The round bottle’s lens effect is undone by ray tracing, and camera shake is estimated from what stands still and removed.

  3. Uncertainty,
    and a methods paragraph.

    Stop recording and the figures (PNG + vector PDF), a report, a methods paragraph for your paper, CSV and VTK are saved automatically.

By the numbers

Every number is from the README’s experiments. Timings are from an Apple M4 Mac; iPad hardware speed has not been measured yet.5

Highlight

A live run with an Insta360 Ace Pro 2 over USB. The picture was drawn again by passing the same recording through the pipeline with the same settings; the bar below shows the values recorded during the live run.

01Live

Analysed
as you film.

An Insta360 Ace Pro 2 in USB webcam mode on an Apple M4 Mac, analysed as it streams by the app’s pipeline: 1920 × 1080 at 30 fps, PIV at ½ resolution with camera-motion correction, 29 fps analysed (19 ms per frame). At full resolution, about 10 fps.

There is no fluid in this scene: a person moving at a desk shows the camera link, the real-time path and the field display. A flow with tracers has not been filmed with this camera yet.

  1. Camera
  2. Background and masks
  3. PIV / PTV
  4. Field and recording
Mean speed and vectors of the vortex in the bottle drawn over the camera image; speed 0 to 5.57 mm/s.

Over the camera image: true velocities at their apparent positions (synthetic).

02Scene corrections

Through the bottle,
in true coordinates.

A cylinder filled with water stretches the picture about 1.33 times near its centre, and more near the wall. LivePTV traces the camera’s rays through wall and fluid (Snell’s law) and maps the results to their true positions and velocities in the measurement plane. The length scale comes from the bottle’s outer diameter and its apparent width.

What it corrects when you film through a bottle or a tank

Reflections, labels, scratches
Removed with a running-mean background
Glare and glints
Static glare and moving glints on the surface masked automatically; anything else can be excluded on screen
The round bottle’s lens effect
3-D ray tracing through wall and fluid, to positions and velocities in the measurement plane
Camera shake
Estimated from what stands still and removed (03)
Time-averaged velocity field of the synthetic vortex in the bottle: speed and vectors, streamlines, vorticity, divergence.
The time-averaged vortex, in true plane coordinatesSpeed and vectors, streamlines, vorticity, divergence, as the app’s pipeline and recorder wrote them at the end of the recording.
Measurement quality: masks, single-vector uncertainty, peak locking and the bottle’s lateral magnification.
Measurement qualityWhat was masked and why, the random uncertainty of single vectors, the sub-pixel histogram (peak locking), the bottle’s magnification.

03Camera motion

The stand sways,
only the flow remains.

Not only shifts: rotation about any point, also far outside the picture (a stand swaying about its foot), rolling-shutter shear and the keystone of a tilting camera are told apart from the static background and removed. The turning point is located and reported. It corrects PTV velocities as well as PIV.

A camera on a stand swaying about a point 900 px below the picture: velocity fluctuation median 12.9 px/s not compensated, 1.1 px/s with automatic compensation; at the right, the learned and the true pivot.
A camera on a stand that sways about its foot, 900 px below the picture (synthetic). From the left: the apparent velocity fluctuation without and with automatic compensation, and the turning point learned against the true one.

The mean field is not the issue (zero-mean shake averages out; for the swaying stand, compensation costs a little: mean-field error 0.94 % without, 1.24 % with); fluctuation and turbulence statistics, and every single PTV step, are.

04Uncertainty and outputs

Stop recording,
the evaluation is there.

Every recording ends with an evaluation folder: publication figures (PNG + vector PDF), a self-contained report.html, a methods.txt paragraph, CSV and VTK. The figures below were written by the app’s own pipeline and recorder; the synthetic scenes have an exact flow, so each caption gives the error of the time-averaged field.

methods.txt

The methods paragraph the app’s pipeline wrote for the synthetic bottle recording, as written.

Velocity fields were obtained by particle image velocimetry (LivePTV) from 150 frames recorded at 30.00 fps (5.0 s of camera time; velocities use camera timestamps). Each frame first had a temporal background removed (running mean with a memory of 300 frames), which suppresses static reflections, labels and scratches on the container. Pixels belonging to static glare (background ≥ max(200, median + 60) grey levels), moving saturated glints (≥ 250 grey levels), everything outside the fluid and a 1.5 mm band inside the container wall were masked (dilated by 3 px); interrogation windows more than 40 % masked were not evaluated. Images were normalised by local contrast (box radius 12 px). Cross-correlation was computed by FFT in 64→32 px interrogation windows (multi-pass with iterative image deformation (Scarano 2002): both frames resampled symmetrically by the previous pass's field, interpolated between vectors by cubic convolution after a 3 × 3 binomial filter (Schrijer & Scarano 2008), with 8-tap Lanczos (windowed-sinc) image interpolation, 3 final iterations, 50 % overlap), with a 3-point Gaussian peak fit corrected for the window-overlap bias (Westerweel 1997). Vectors with a normalised correlation below 0.20 or failing the normalised median test (threshold 2.0, ε = 0.10 px; Westerweel & Scarano 2005) were rejected and replaced by the median of their neighbours (excluded from statistics). 99.9 % of the evaluated vectors were valid (34.1 % of windows masked). The random uncertainty of single vectors, estimated from correlation statistics (Wieneke 2015), had a median of 0.007 px per pair (95th percentile 0.025 px). The particle-image diameter inferred from the correlation-peak width was 3.7 px (peak-locking index 0.00). Refraction by the container was corrected by tracing the camera ray of every image point through the wall into the measurement plane (Snell's law in 3-D; cylinder ⌀60.0 mm, wall 2.00 mm (n=1.474), fluid n=1.333, plane +0.0 mm from the axis, distant camera; refraction corrected; lateral magnification at the centre 0.750). Displacements were mapped end to end, and the time-averaged field was resampled on a regular grid in true plane coordinates. The length scale was 0.12 mm per pixel (container silhouette (⌀60.00 mm outer)). Statistics were accumulated on a 26 × 25 grid (16 px cells); 630 cells had at least 10 samples. The statistical uncertainty of the mean is the standard error of the samples in each cell (median 0.1 % of the local speed).

05Particle tracking

Tracks particles,
their diffusion and size.

trackpy’s bulk_water sample (1 µm latex spheres in water, 24 fps) played into the app as a video file, PTV mode: tracks, the diffusion coefficient and the Stokes–Einstein diameter. With the same estimator, LivePTV and trackpy agree within 1 % (lag 1–2: 1,252 vs 1,243 nm) and 4 % (10-lag MSD fit: 983 vs 1,021 nm).

LivePTV tracks of Brownian spheres, ensemble mean squared displacement, and particle sizes from LivePTV and trackpy.
LivePTV tracks (first 5 s, longer than 60 frames), the ensemble MSD with drift removed, and the Stokes–Einstein diameter (nominal 1 µm, water at 20 °C).

Where it does not lead: small particle images (1.5 px) in heavy noise (σ 8, 0.002 particles/px), where detection recall fell from 0.65 in the previous version to 0.57 (trackpy 0.58).

06How it compares

Existing tools, on the same images.LivePTV was run against OpenPIV 0.26.3 (iterative image deformation, the same family as PIVlab), trackpy 0.7 and OpenCV on identical images. PIVlab and commercial packages were not run.

Recorded Ace Pro 2 stream, 1920 × 1080

Real camera

Two consecutive frames from a still moment, the second warped by a known field (1.3 px drift + a 4 px vortex). Median error in textured windows: LivePTV 0.089 px, OpenPIV 0.195 px, OpenCV DIS 0.272 px, Farnebäck 0.429 px. Time per pair: 52 ms, 2.3 s, 52 ms, 142 ms.

On the still background OpenPIV is slightly quieter than LivePTV in textured windows (p95 0.11 vs 0.18 px).

Error maps of the four tools on real camera frames with a known displacement: LivePTV 0.089, OpenPIV 0.195, OpenCV DIS 0.272, Farnebäck 0.429 px.

07GPU

Correlation on the GPU,
the same vectors as the CPU.

Image deformation and the 32-px correlation passes run on the GPU (Metal) with the same vectors as the CPU path (tested to 1·10⁻⁴ px; deformed frames bit-identical). The shader is compiled at run time, so it also works in Swift Playgrounds. Falls back to the CPU (Accelerate) on GPUs older than Apple7.

08Capabilities

What it does,
and what it doesn’t.

From public documentation, release notes and source code (November 2026). Commercial tools were not tested.

CapabilityLivePTV 0.8PIVlab 3.14 / 4.0 βOpenPIV 0.26PaIRS-UniNa 0.2DaVis 11, DynamicStudio, Insight 4Gtrackpy 0.7
Runs oniPad, MacMATLAB, Windows appPythonWindows, macOS, LinuxWindowsPython
Analysis while filmingyes (GPU)camera control and live image; live PIV not implementednonovendor “real-time / online” modesno
Iterative image deformationyesyesyesyesyes–
Per-vector uncertaintyyes (correlation statistics)yes (image matching)no (signal-to-noise only)noyes–
Ensemble correlationyesyesnostatistics onlyyes–
Refraction through a round containeryes, livenonoyes (offline)not documented–
Lens distortion, stereo, 3-Dnodistortion, stereo (4.0 β)noyesyes (incl. Shake-the-Box)–
Particle tracking2-D, livenonono3-D LPT / Shake-the-Box2-D and N-D, offline
Report with methods paragraphyes–––––
LicenseMITMITGPL-3.0LGPL-3.0commercialBSD-3

Getting started

On an iPad, on a Mac,
from code.

Technical
Specifications

Platforms
iPadOS 17, macOS 14 or later
Built with
Swift (5.10 or later), Accelerate, Metal, SwiftUI. GPU correlation on Apple7 GPUs or newer (older GPUs use the CPU)
Sources
USB/UVC cameras on iPad and Mac, video files, synthetic flows (vortex, vortex pair, Taylor–Green array, rotation, channel, uniform, Brownian, camera shake). Insta360 Ace Pro 2 over its own Wi-Fi (not yet verified on hardware)
PIV
Multi-pass FFT cross-correlation (64 → 32 px) with iterative image deformation (symmetric, 8-tap Lanczos), overlap-unbiased 3-point Gaussian peak fit, correlation threshold, normalised median test, adaptive pair spacing for slow flows
PTV
Detection above a robust noise threshold with a background that does not learn the particles, 3-point Gaussian sub-pixel positions, tracking by global minimum-cost assignment with speed-dependent gates, Brownian diffusion and Stokes–Einstein size
Corrections
Running-mean background removal, static-glare and moving-glint masks, user exclusions, refraction in round bottles and flat tanks (3-D ray tracing), camera motion (shift, rotation about any point, zoom, shear, keystone)
Outputs
report.html, methods.txt, publication figures (PNG + vector PDF), CSV, VTK (ParaView), raw per-frame records, bit-exact preview stream
Validation
The README’s validation numbers are all asserted by ./scripts/test.sh
Version
0.7.0 · 2026.11.24. main carries the later changes (GPU (Metal) correlation, image deformation, corrected vector positions, camera motion beyond a shift, PTV improvements), not yet released
Started
2026.11
Source
GitHub · Rhizobium-gits/LivePTV
License
MIT License(Copyright (c) 2026 Rhizobium-gits)
Citation
If you use LivePTV in published work, please cite it (CITATION.cff) and the method papers listed in the methods document’s references

Notes

  1. The iPad app is built from the source code with Xcode. Without Xcode, ./scripts/make-swiftpm.sh builds a Swift Playgrounds package that runs on the iPad itself (unoptimised, about 3× slower).
  2. The Insta360 Ace Pro 2 Wi-Fi protocol is community-documented and tested only against a protocol-accurate mock camera. Verify it with ace-probe before relying on it. USB cameras work: tested live with an Ace Pro 2 in webcam mode on a Mac (1080p30).
  3. Refraction is corrected for one measurement plane. With volume illumination of turbid fluid, the image is depth-averaged. This and the other assumptions (optical axis, lens distortion, temperature-dependent refractive indices) are in the methods document’s “Limitations and recommendations”.
  4. Velocities use camera timestamps. The live preview is compressed; keep the camera’s own recording for re-analysis.
  5. The comparisons use synthetic images (exact truth, no lens or compression), public sample recordings (no truth) and a real camera recording. PIVlab and commercial packages were not run. iPad hardware speed has not been measured yet (all timings: Apple M4 Mac).
  6. The film at the top: particle images (1920 × 1080; 1200 × 1200 on portrait screens) from LivePTV’s synthetic source (a counter-rotating vortex pair, also in the app’s demo source) through LivePTV’s analysis pipeline (default settings, with PIV at ½ resolution), drawn the way ace-probe draws its live overlay. The vortices’ strength, size and spacing and the number of particles were chosen for this film. Arrows: displacement over 0.5 s; colour: speed.

Measuring a flow in a bottle,
in six steps.

  1. Prepare the bottle

    Fill and seed the bottle (or use the turbidity of the fluid itself). Fix the camera on a stand, perpendicular to the bottle, and use the camera’s linear (distortion-corrected) mode. A light sheet through the axis defines the measurement plane best.

  2. Start the preview

    In the app, choose the source and start the preview.

  3. Mark the outline

    Container › Round bottle, then Mark container outline. Drag from one outer edge of the bottle to the other, from just below the free surface to just above the base.

  4. Diameter, wall, materials

    In Analysis settings › Container and refraction, enter the outer diameter, the wall thickness and the materials (presets for glass, PMMA, PET, water, glycerol and more). The length scale now comes from the silhouette.

  5. Background and exclusions

    Leave Background removal on the running mean. Use Add exclusion for labels or reflections that are still visible. Show masked areas displays what is ignored.

  6. Record, then stop

    Start recording, then stop. The session folder contains the evaluation, figures, the methods paragraph and all raw data (Files app: On My iPad › LivePTV › Sessions).

Source code (.zip) Documents Downloads

For a flat-walled tank, calibrate mm/px with a target in the measurement plane. Alternatively, calibrate on the outer wall, give the camera distance, and enable calibrated on the outer wall.