Notes ·
What the pond teaches about re-identification
The koi pond on the home page is a toy with real failure modes: a noisy detector, a confirmation gate, a tracker that loses IDs under occlusion, and a count that drifts up, which re-identification cuts by about four fifths.
The koi pond on the home page is a synthetic scene: a seeded simulation drawn on a canvas, with no footage and nothing uploaded. I built it because the hard part of counting things in video is not detecting them. It is keeping the same identity on the same object long enough to count it once.
What is in the pond
Seven to nine fish (eight in the default pond) swim in a pond drawn at 30 steps a second from one seed, so a reload shows the same pond. Above them sits a deliberately imperfect detector:
- it misses a fish with a probability of 4 percent plus 8 percent of the fish's depth, so deep fish go missing more often;
- when two boxes overlap by more than 0.3 IoU it merges them 60 percent of the time, which is what happens when fish crowd together;
- now and then it reads a ripple as a fish, at a confidence between 0.12 and 0.46 (a base of 0.12 plus a random part of up to 0.34: 0.12 + 0.34 = 0.46);
- it reads each fish's pattern class correctly 89.5 percent of the time, out of four classes: it keeps the true class 86 percent of the time and otherwise guesses at random, which still lands on the right class a quarter of the time (86 + 14 / 4 = 89.5).
A confidence gate, 0.45 by default, decides which boxes count. A small tracker then associates boxes to tracks greedily by IoU, keeps a track alive for 0.6 seconds without a detection, and confirms a track after three hits. The pond is counted by confirmed unique IDs.
Lesson one: counting is tracking
Every time a fish is lost and found again it gets a new ID, and the count goes up by one. Feeding pulls the fish together, which is exactly where occlusion and merged boxes happen, so the ID count drifts away from the fish count a few seconds after you tap the water. The number of fish never changed. The tracker's memory did.
Lesson two: the gate is not what keeps ripples out
Drag the gate up and real fish vanish when their confidence dips, then come back as new IDs, so the count climbs. Drag it down and the ripples get through as boxes, but they appear at random places, never collect three hits in a row, and so never become confirmed tracks. In the pond, the confirmation rule protects the count, not the gate. Real footage is less kind: false positives there tend to repeat in the same spot, frame after frame, so a low gate does let them confirm. That is why the real pipeline I worked on needed a gate that adapts to the scene rather than one number for sparse and dense frames alike.
Lesson three: re-identification needs memory and a signal
With re-identification on, a lost confirmed track is remembered for five seconds. A new detection with a matching pattern class is handed the old ID instead of a new one. Over 30 seeded runs (seeds 2026 to 2055, a pond twice as wide as it is tall, one feed at the centre), the feed added about 5.6 extra IDs within 20 seconds without re-identification and about 1.1 with it (5.57 and 1.10 on average): the drift falls by about four fifths, and stops entirely in 9 of the 30 runs. It is not free: the detector's pattern guess is wrong 10.5 percent of the time (100 - 89.5 = 10.5), so some fish are re-identified as the wrong fish, and a fish hidden for longer than the memory window is lost for good. Those are the real trade-offs of appearance-based re-ID, scaled down.
The walkthrough under the pond replays these steps on one seeded pond, and the panel beneath it lists each of the 30 runs above as IDs minus fish, with and without re-identification (the walkthrough calls it track-linking), from the same simulation code; scripts/pond-overcount.ts reproduces that panel.
Why a toy
My internship work on field-video counting is under NDA, so the pond carries the shape of the problem and none of the data. The track-linking layer and the size-aware confidence threshold I built there existed for the same reason the pond drifts: double counts across sparse and dense scenes. Pause the pond, step it frame by frame, and watch the IDs and the fish count in the readout. The gap between them is the whole job.