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.
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.
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.
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
29fps
A USB camera’s 1920 × 1080 stream, analysed live by PIV at ½ resolution (19 ms per frame)
1.9%
Error for a vortex in a 60 mm glass bottle with reflections and glints (synthetic). A naive analysis: 34.5 %
0.089px
Median error in textured windows with a known motion applied to real camera frames (OpenPIV 0.195 px)
39ms
PIV of one 1920 × 1080 pair (GPU, Apple M4). OpenPIV 0.26: 2.1 s
Every number is from the README’s experiments. Timings are from an Apple M4 Mac; iPad hardware speed has not been measured yet.5
-
Analysed
as you film.A real camera, 1920 × 1080 at 30 fps.
-
Through the bottle,
in true coordinates.Reflections, glare and the lens effect, corrected.
-
The stand sways,
only the flow remains.Even a turning point outside the picture is found.
-
Stop recording,
the evaluation is there.Figures, report, methods paragraph, CSV, VTK.
-
Tracks particles,
their diffusion and size.Agrees with trackpy on a real microscopy video.
-
Existing tools,
the same images.Compared with OpenPIV, trackpy and OpenCV.
-
Correlation on the GPU,
the same vectors as the CPU.A 1920 × 1080 pair in 39 ms.
-
What it does,
and what it doesn’t.Next to other tools, from public documentation.
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.
- Camera
- Background and masks
- PIV / PTV
- Field and recording
What it takes in.
USB/UVC cameras on iPad and Mac, video files, and synthetic flows with known ground truth. The Insta360 Ace Pro 2 over its own Wi-Fi too, not yet verified on hardware.2
2 frames skipped in 45 s.
2 of 1,334 frames skipped by the analysis. Velocities use the camera’s timestamps.
A real camera, four faults fixed.
A camera that stays silent at first, a camera-motion correction of up to 516 px for a still camera at ½ resolution, a “pivot” fitted to noise, and an empty live field with long pairs. Synthetic tests had missed them.
Keep the camera’s recording.
The live preview is compressed and poorer than the camera’s own recording; keep that recording for re-analysis.

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)
1.9 %naive analysis 34.5 %
A vortex in a 60 mm glass bottle.
A synthetic scene with reflection stripes on the glass, a saturated hot spot and a glint travelling along the free surface. Relative RMS error of the time-averaged field.
0.170 → 0.030 px
A uniform flow under a reflection stripe, a hot spot and a moving glint.
Vectors off by more than 0.5 px: 2.2 % → 0 %.
0.451 → 0.046 px
A uniform flow through a 56 mm bottle.
Error on images of a uniform flow filmed through the bottle.
≤ 1.2·10⁻⁴ mm
Ray tracer against closed-form optics.
Centre magnification 0.7502 = 1/n.


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.

13.96 → 1.17 px/s
Apparent fluctuation of the static border.
The turning point was located within 15 px and reported as outside the frame.
10.54 → 2.54 px/s
PTV velocity error.
Every particle step has the camera motion between its frames subtracted.
4.82 → 1.45 px/s
Rolling shutter and keystone.
Shift + rotation + zoom only, against the automatically chosen model.
516 → 1.2 px
A real camera, a still room.
Largest correction applied at the frame edge at ½ resolution. Before the fix, clustered noise was fitted as rotation and keystone.
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.
![Time-averaged velocity field of a counter-rotating vortex pair: speed and vectors, streamlines, vorticity, divergence.]()
Counter-rotating vortex pairSpeed and vectors, evenly spaced streamlines, vorticity (sign shown), divergence as a check of planar flow. Mean field within 0.32 % of the exact flow. ![Time-averaged velocity field of a Taylor–Green vortex array.]()
Taylor–Green vortex arrayTwelve cells of alternating rotation. 0.23 %. ![Channel flow: velocity profiles with error bars.]()
Channel (Poiseuille) flowCentre-line profiles with ±2 standard errors and the ±1 SD fluctuation band. 0.81 %. ![Ensemble-correlation field of faint, sparse Brownian tracers.]()
Faint, sparse, Brownian tracers (µPIV-like)Ensemble correlation over 149 pairs: 7.4 % error, where averaging single-pair vectors gives 11.8 %.
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).
Every vector, with its uncertainty.
Random uncertainty of every vector from correlation statistics (predicted ÷ actual error 0.72–1.48 over the test and benchmark conditions); noise-corrected fluctuations; standard errors of the mean.
Ensemble correlation and diagnostics.
Ensemble correlation (µPIV) for faint, sparse particles; particle-image diameter and peak-locking diagnostics.
Everything in the recording folder.
session.json with every setting, the camera and the calibration; per-frame records (frames.csv, piv_vectors.csv and more); the received preview stream, bit-exact.
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).

0.98 / 0.97
Right links in fast, dense flows.
5000 particles, 10 px per frame (1.4 particle spacings): links right, precision / recall. trackpy with a velocity predictor: 0.77 / 0.67.
0.76–0.89
Detection recall in dense images.
0.01 particles/px, 2.5–4 px images. The previous version (0.7): 0.45–0.53. Precision 0.997 in the worst condition; pure noise gives no detections.
+3 %
Brownian diffusion coefficient, synthetic.
The previous version: +37 %. Its background learned the slow particles and pushed them along their motion.
52 ms
A frame with about 20,000 particles.
Detect + track at 1920 × 1080 (17,500 found). trackpy: 0.49 s (10,700 found).
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).
Synthetic images, known truth
Vortices
Lamb–Oseen vortex, core 30 px: RMS error 0.023 px. OpenPIV 0.053 px, the previous version (0.7) 0.111 px. Core 60 px: 0.008 px (OpenPIV 0.018 px).
The figure is one example pair; the numbers in it differ from the values above (over 4 pairs).
Synthetic images, sinusoidal displacement
Resolution
Shortest wavelength kept at 90 % amplitude with 32-px windows: LivePTV 80 px, OpenPIV 63 px. OpenPIV keeps slightly finer detail at default settings.
LivePTV filters its deformation predictor to keep the noise down; switch Smooth the predictor off: 65 px, at about twice the random error.
Synthetic images, one condition changed at a time
Difficult images
Sparse seeding (0.005 particles/px): 0.040 px (OpenPIV 0.073 px). Heavy noise (σ = 24 grey levels): 0.081 px (0.103 px). Ahead of OpenPIV in every condition, out-of-plane motion included.
In this test (with image deformation), the reported uncertainty is within ×0.84–1.48 of the actual error.
OpenPIV’s sample recordings, no ground truth
Real recordings
LivePTV and OpenPIV agree to a median of 0.02–0.07 px. LivePTV takes 6–94 ms per pair, OpenPIV 0.2–4 s.
Both tools produce scattered vectors in regions without particles (behind the plate); LivePTV’s are somewhat wilder there.
Synthetic, Taylor–Green flow
Particle tracking
5000 particles at 1.4 particle spacings per frame: links right 0.98 / 0.97 (trackpy with a velocity predictor 0.77 / 0.67). Detection recall in dense images (0.01 particles/px, 2.5–4 px images): 0.76–0.89 (trackpy, tuned per condition: 0.77–0.87).
Apple M4, 64 → 32 px, three final iterations
Speed
PIV per pair: 17 ms at 1280 × 720 (CPU only 27 ms, OpenPIV 0.91 s), 39 ms at 1920 × 1080 (67 ms, 2.1 s).
OpenPIV and trackpy ran in one Python process, as they do by default; both can be parallelised over image pairs.
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.
17 ms
A 1280 × 720 pair.
27 ms CPU only.
39 ms
A 1920 × 1080 pair.
67 ms CPU only.
6–94 ms
OpenPIV’s real recordings.
From 511 × 369 to 1720 × 2304. OpenPIV: 0.19–4.1 s.
iPad
Not measured on the iPad yet.
All timings are from an Apple M4 Mac. An unoptimised build (Swift Playgrounds) is about 3× slower.
08Capabilities
What it does,
and what it doesn’t.
From public documentation, release notes and source code (November 2026). Commercial tools were not tested.
| Capability | LivePTV 0.8 | PIVlab 3.14 / 4.0 β | OpenPIV 0.26 | PaIRS-UniNa 0.2 | DaVis 11, DynamicStudio, Insight 4G | trackpy 0.7 |
|---|---|---|---|---|---|---|
| Runs on | iPad, Mac | MATLAB, Windows app | Python | Windows, macOS, Linux | Windows | Python |
| Analysis while filming | yes (GPU) | camera control and live image; live PIV not implemented | no | no | vendor “real-time / online” modes | no |
| Iterative image deformation | yes | yes | yes | yes | yes | – |
| Per-vector uncertainty | yes (correlation statistics) | yes (image matching) | no (signal-to-noise only) | no | yes | – |
| Ensemble correlation | yes | yes | no | statistics only | yes | – |
| Refraction through a round container | yes, live | no | no | yes (offline) | not documented | – |
| Lens distortion, stereo, 3-D | no | distortion, stereo (4.0 β) | no | yes | yes (incl. Shake-the-Box) | – |
| Particle tracking | 2-D, live | no | no | no | 3-D LPT / Shake-the-Box | 2-D and N-D, offline |
| Report with methods paragraph | yes | – | – | – | – | – |
| License | MIT | MIT | GPL-3.0 | LGPL-3.0 | commercial | BSD-3 |
Getting started
On an iPad, on a Mac,
from code.
iPad app (Xcode)
Open LivePTV.xcodeproj, choose your team under Signing & Capabilities (a free Apple ID works), select your iPad and run. The scheme builds Release (the analysis needs compiler optimisation).
Without Xcode
./scripts/make-swiftpm.shbuilds a Swift Playgrounds package that runs on the iPad itself (unoptimised, about 3× slower).As a Swift package
Depend on
PTVCore(algorithms only) orLivePTVKit(sources, pipeline, recording, SwiftUI app).Tests and tools on a Mac
Command Line Tools are enough.
./scripts/test.shruns the tests (algorithms, optics, GPU vs CPU, end-to-end recordings);ace-probebenchmarks and checks the camera.Measuring in a bottle
Mark the bottle’s outline, enter its diameter, wall and materials, start recording and stop. The six steps are at the bottom of this page.
How every number is computed
How every number is computed, why, and how it was validated: the methods document (METHODS), in English and Japanese.
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
- The iPad app is built from the source code with Xcode. Without Xcode,
./scripts/make-swiftpm.shbuilds a Swift Playgrounds package that runs on the iPad itself (unoptimised, about 3× slower). - The Insta360 Ace Pro 2 Wi-Fi protocol is community-documented and tested only against a protocol-accurate mock camera. Verify it with
ace-probebefore relying on it. USB cameras work: tested live with an Ace Pro 2 in webcam mode on a Mac (1080p30). - 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”.
- Velocities use camera timestamps. The live preview is compressed; keep the camera’s own recording for re-analysis.
- 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).
- 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.
OpenPIV, trackpy, PIVlab, PaIRS-UniNa, DaVis, DynamicStudio, Insight 4G, OpenCV and Insta360 belong to their respective owners.
Apple, iPad, Mac and macOS are trademarks of Apple Inc., registered in the U.S. and other countries and regions.
Measuring a flow in a bottle,
in six steps.
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.
Start the preview
In the app, choose the source and start the preview.
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.
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.
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.
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.




