Counting Steps by Watching Paws: Auto-Labeling Dog Gait to Tune an IMU Tracker
Our IMU-based activity tracker clips to a dog's collar and, in principle, can tell you how far your dog walked today. In practice it needs a teacher. An accelerometer strapped to a moving neck produces a beautiful, noisy waltz of a signal, and turning that waltz into a step count means picking thresholds, windows, and rules — and every one of those choices needs a ground truth to check against. The problem is that nobody wants to sit and hand-count paw strikes in an hour of treadmill footage. So we built something to do the counting for us: a pose model that watches the paws and marks a step every time one swings forward.
Why a Treadmill and a Camera
The setup is deliberately boring, because boring is what makes the labels trustworthy. A dog walks on a treadmill while a camera films from the side. The treadmill fixes the dog roughly in place so it stays in frame for the whole clip, and the side view puts all four paws on display as they cycle through the air and back to the belt. On the collar sits the tracker we actually care about. The camera's job is not to be the product — it is to be the answer key. If the pose pipeline can tell us "the left front paw struck the ground here, and here, and here," we have a per-step timeline to line the IMU signal up against.
Our clip is a short window pulled from a treadmill review video. A handful of seconds of steady trotting is enough: gait is periodic, so a clean thirty-second stretch contains dozens of strides per paw, which is plenty to calibrate against.
Twenty-Four Points on a Dog
The model is a YOLO pose network trained on a 24-keypoint dog skeleton — the same schema Ultralytics uses for its dog-pose work. Twenty-four points is enough to sketch a whole dog: a spine, a tail base, elbows and hocks, and, crucially, one keypoint per paw. We only need four of those points to count steps — front-left, front-right, rear-left, rear-right — but the rest earn their keep by anchoring the body, and by making the annotated video legible to a human reviewer who wants to sanity-check the result.
Inference runs once over the clip and the raw keypoints are cached to disk. That detail sounds like housekeeping, but it matters: gait analysis is iterative, and you do not want to re-run a neural network every time you nudge a peak-detection threshold. Run the model once, then experiment on the numbers for free.
Subtracting the Body from the Paw
Here is the trick that makes the whole thing work. A paw's raw horizontal position in the image is not a clean signal, because the dog itself drifts — it slides a little forward and back on the belt, it sways, the treadmill nudges it around. If you count peaks in the raw paw position, you are counting the dog's wobble as much as its strides.
So we do not track the paw in the image. We track the paw relative to the body. The body anchor is the average horizontal position of a few stable interior keypoints — the two elbows and the tail base — which together trace where the torso is at each frame. Subtract that anchor from each paw's position and the body's drift cancels out. What remains is the paw's motion in the dog's own frame of reference: a clean back-and-forth as the leg reaches forward and plants down, stride after stride.
Before any of that, each paw's trace is cleaned up. Low-confidence detections are thrown away, the gaps they leave are interpolated across, and the result is smoothed with a Savitzky-Golay filter — a smoother that flattens jitter without blunting the peaks we are trying to find. A paw that the model only saw clearly half the time still yields a usable curve.

Finding the Rhythm Before Counting the Beats
A step is a peak in that relative-position curve — the moment the paw reaches the front of its swing. But peaks come in all sizes, and a naive peak-finder will happily invent extra steps out of tiny wiggles or miss real ones buried under noise. To count reliably we first need to know roughly how fast the dog is stepping, so we can tell a real stride apart from a ripple.
All four legs share one stride frequency — a trotting dog does not run its front legs at a different tempo from its back — so we can estimate that frequency from the paws themselves. Each paw's curve is run through an autocorrelation, which asks "how far do I have to slide this signal against itself before it lines back up?" The answer is the stride period. We look only in the physically plausible band, somewhere between roughly half a second and two seconds per stride, take the strongest match from each paw, and use the median across paws as the dog's dominant gait period.
With that period in hand, counting becomes principled. Each paw's forward-swing peaks are detected with two guardrails: peaks must be separated by at least seventy percent of a stride period, so no single stride gets counted twice, and each peak must clear a prominence floor scaled to that paw's own swing amplitude, so shallow noise never registers as a step. One clean peak per stride, per paw.
Showing the Work
Numbers you cannot see are numbers you cannot trust, so the pipeline renders a second video with everything drawn on top. The full 24-point skeleton is overlaid in green, each paw gets its own colored marker, and a running step counter ticks up in the corner alongside the elapsed time and a live steps-per-minute readout. The moment a step is detected, a white ring flashes on that paw for a few frames — a touchdown marker you can watch land.
This is what turns the tool from a black box into an answer key. A reviewer can scrub through the clip and confirm, with their own eyes, that the ring flashes when the paw actually swings forward and not at some random moment. If the count is wrong, the video shows you exactly where and why. Alongside the video, the pipeline writes out the per-paw signals and detected peaks for plotting, and a summary with the totals: steps per paw, total steps, steps per minute, the stride period it settled on, the model's detection rate, and how much of each paw it could see.

Where It Gets Hard
Honesty section. This annotator is good enough to tune against, but it is not magic, and three things limit it.
It only counts what it can see. When a paw is occluded — a far-side leg hidden behind the near-side body, or a frame where the model's confidence dips below threshold — that paw's coverage drops, and coverage is reported precisely so nobody quietly trusts a paw the model barely saw. Interpolation papers over short gaps; it cannot invent a stride that was never observed.
It assumes a steady gait. The autocorrelation step finds one dominant stride period and the counting leans on it. That is exactly right for a dog trotting evenly on a treadmill, which is why we film on a treadmill. Turn it loose on a dog that keeps changing pace, stopping to sniff and bolting forward, and the single-period assumption starts to strain.
And it measures the front of the swing, not the strike on the belt. We count the forward-swing peak because it is the cleanest, most repeatable landmark in the relative-position curve. That is a consistent, countable event — one per stride — but it lands slightly before the paw actually contacts the ground. For calibrating step counts that offset is harmless, since we care about how many and how often. If we ever needed exact ground-contact timing, we would want the vertical paw trace or a real force plate to pin the moment down.
The Point of All This
None of this pipeline ships in the product. The camera, the treadmill, the 24-point skeleton, the autocorrelation — all of it exists to produce one modest artifact: a trustworthy list of timestamps saying "a step happened here." That list is the teacher. With it, we can take the messy accelerometer trace from the collar, lay the true steps underneath it, and finally answer the questions that matter for the tracker — which peaks in the IMU signal correspond to real strides, what threshold separates a step from a head-shake, how the neck's motion relates to the paw's.
There is a nice inversion buried in this. The camera is a far better step-counter than the IMU will ever be, but it is useless on a collar in the real world — it cannot ride along on a walk in the park. The IMU is the opposite: cheap, tiny, always-on, and hopeless without calibration. So we let the good sensor teach the practical one, once, in a controlled room, and then send the practical one out into the world knowing what a step feels like. The paws did the counting so the collar could learn the rhythm.