Keep reading
You are hereHow does a camera measure motion?
Interactive Physics Textbook · Reading path
A camera records only pixels at fixed frames. Calibrate them into positions, estimate velocity from differences or local fits, and find where noise enters.
Pixels do not tell us velocity directly. A camera records only which pixel column the object falls on in each frame. To get a velocity, we first calibrate pixels into positions, then estimate a slope from how the position changes over a few neighbouring frames. The result carries the effects of the motion, the camera and the analysis method all at once, so each has to be checked separately.
You will need Chapter 1’s distinction between average velocity and the slope at one instant. Here you will learn to choose a calibration and a fitting window, then judge whether a velocity curve is resolved by the recording. In the last chapter the position curve was given to us. Now the question changes. A fixed camera films a straight track at 30 frames per second. A ball oscillates back and forth along the track while drifting slowly to the right. All we have is the pixel column in each frame. Can we read the ball's velocity at each moment from those numbers?
The tables and figure in this chapter come from the Motion Measurement and Numerical Differentiation Lab. There the motion is given by a known formula, so estimates can be compared with the truth. A real experiment has no such truth to compare against, only the checks this chapter introduces.
The camera takes frames at a fixed frame rate , so neighbouring frames are apart. Counting from zero, frame is taken at . At the frame interval is about .
In each frame, a tracking program finds the pixel column of the ball's centre. A record is a list of number pairs . It contains no positions and certainly no velocities: positions come from a calibration, and velocities from a calculation.
This distinction runs through the whole chapter. What is recorded directly is an observation; what we compute from observations is an estimate. An estimate's error comes partly from the observations and partly from the algorithm we chose.
The Lab's default record lasts and has 121 frames. The sensor is 2048 columns wide, and column 1024 is lined up with the origin of the track. Take rightward along the track as positive, in metres. The ball's true motion is
The defaults are , , , , and . The frequency counts oscillations per second; is the angular frequency, in radians per second, and the sine takes its argument in radians. The ball goes back and forth once every two seconds while drifting right at .
To compare estimates with the truth we need this motion's velocity. Chapter 1 found slopes of polynomials only, so here we use a symmetric average velocity to find the slope of a sine.
Take two times a step either side of . The identity gives
As goes to zero, goes to 1. This is the small-angle fact that the sine of a small angle is almost equal to the angle in radians; for example, . So
The oscillating part of the velocity has amplitude . Adding the rightward drift gives a maximum speed of . The ratio will return in Section 2.5, where it sets how much a difference underestimates the velocity.
If the camera scale is pixels per metre and the origin sits at column , then
This single-scale calibration assumes the track stays in one plane at a fixed distance from a stationary camera, with negligible perspective and lens distortion along it. Photograph the ruler in that same plane; a ruler closer to the lens gives the wrong scale.
In the Lab, and , so one pixel corresponds to about . In a real experiment you usually photograph a ruler of known length, count how many pixels it spans, and get from that.
Calibration can go wrong in two ways, with very different effects.
A wrong scale stretches every position by the same factor. If the assumed scale is 10% larger than the true one, every position, displacement and velocity is divided by 1.1. The error is proportional to the quantity being measured: the further the ball goes, the larger the position error.
A wrong origin shifts every position by the same distance. An origin 12 pixels off moves every position by . The shift cancels when two positions are subtracted, so velocities are unaffected.
The Lab's “Uniform motion” preset moves the ball at a steady with no noise. With a 10% scale error, the velocity error is exactly . With a 12-pixel origin error, the position error is and the velocity error is zero. Both results follow from the formula above without the Lab.
A record has more than a hundred estimates, each with an error . To compare two methods we need to sum the list up in a few numbers.
The mean says whether the errors lean to one side. The standard deviation says how widely they spread around the mean. The root mean square (RMS) includes both:
Write as , square and sum. The cross term sums to zero, because the deviations cancel in total. Hence
With the assumed origin 12 pixels too high, the position errors have a mean of , a standard deviation of zero and an RMS of . Every RMS error the Lab reports is the RMS of the difference between an estimate and the known truth, which only a simulation can compute directly.
The same argument shows something else. When two errors are uncorrelated, their deviations from their means have a zero average product. The variance of their sum is then the sum of their variances. This is a statement about the noise distribution; a short record need not have an exactly zero cross term. Correlated errors require the covariance term in the NIST law of uncertainty propagation. This chapter uses that rule several times.
In every frame the Lab adds a perturbation between pixels and then rounds the result to a whole pixel. The perturbation comes from a fixed formula, so it is not truly random noise, but over many frames it spreads roughly evenly across that interval. A quantity spread evenly between has a standard deviation of . We use that result here without proof; deriving it needs the integral of .
The perturbation's standard deviation is pixels. The rounding error lies between pixels too. If it is approximately uniform and uncorrelated with the perturbation, its standard deviation is also about 0.29 pixels. Adding the squares and taking the square root gives about 0.41 pixels, or . The Lab's raw position RMS error for the default record is , in line with the estimate.
The simplest estimate is the average velocity between neighbouring frames. To make the estimate belong to the time of one frame, we usually take the frames on either side. This is the three-point central difference:
The hat marks an estimate. It has two kinds of error, with different causes, and they move in opposite directions as the frame rate changes.
The first is truncation error, from replacing an instant by a finite stretch of time. For constant acceleration the formula is exact: substitute and the parts of the two terms subtract to leave , which is the instantaneous velocity. For the sinusoidal part, Section 2.2 already showed that the difference gives that component of the true velocity times .
At , and the ratio is 0.99817. The oscillating velocity amplitude is underestimated by about 0.18%, an error amplitude of about and an RMS of about . With the Lab's noise and rounding switched off, the three-point velocity RMS error is .
The second error comes from position noise. Assume errors in the two positions are uncorrelated and each has standard deviation . Their difference has a standard deviation of , and dividing by gives
With and this is about . On the Lab's default record, the three-point difference gives a velocity RMS error of . That is more than ten times the truncation error, so noise is the main problem here.
Pixels make the point clearer. The three-point difference can be written , and with the default settings the denominator is 8 pixel seconds per metre. A difference of a single pixel between the two frames changes the velocity estimate by .
A higher frame rate reduces truncation error but amplifies noise. At the raw position error is about , the formula predicts about , and the Lab gives , roughly four times the value. Filming more often makes the three-point difference worse.
Acceleration needs a second difference, which amplifies noise even more. On the default record the three-point formula has an acceleration RMS error of about , comparable with the true acceleration amplitude .
With only two frames there is nothing to average the noise over. The remedy is to take frames centred on frame , fit a quadratic curve through them, and use the curve's slope at the centre.
The fit chooses the curve that makes the sum of squared vertical distances from the points smallest. This is a least-squares fit, discussed in detail in Chapter 3. Savitzky and Golay in 1964 gave a convenient algorithm for smoothing and differentiating data with such local polynomial fits.
Label the frames in the window by offsets . Because the window is symmetric, and both sum to zero, so the constant and quadratic terms do not affect the slope. The centre slope equals the slope of a straight-line fit:
With this is exactly the three-point difference. For equally spaced frames with uncorrelated noise of equal standard deviation , as the window widens, in the denominator grows quickly and more of the noise averages out:
A nine-frame window has , leaving only about of noise. The price is smoothing. Nine frames span , during which the velocity changes appreciably, and the fitted slope flattens its peaks and troughs. Table 2.1 lists the results on the default record.
| Method | Valid estimates | Velocity RMS error () | Acceleration RMS error () |
|---|---|---|---|
| Three-point difference | 119 | 0.068 | 8.00 |
| Five-frame fit | 117 | 0.037 | 1.59 |
| Nine-frame fit (Lab default) | 113 | 0.069 | 0.357 |
| Fifteen-frame fit | 107 | 0.190 | 0.467 |
| Thirty-one-frame fit | 91 | 0.793 | 1.83 |
The velocity error falls and then rises again, with its minimum near five frames. The nine-frame error comes mostly from smoothing: with noise and rounding switched off, its velocity error is still , almost the same as with noise. Acceleration needs a wider window to suppress the noise, so the best window differs between the two columns.
Figure 2.1 Three velocity estimates from the same default record. The grey curve is the reference velocity from the Lab's formula; dots are the three-point difference, the thin line the five-frame fit and the thick line the thirty-one-frame fit.
The three-point difference jumps around the reference. The thirty-one-frame fit is smooth but clearly cuts the peaks. The five-frame fit sits between them. All three estimates use only the recorded pixels and the calibration.
How wide a window should be depends on how long it lasts compared with how fast the motion changes, not on the number of frames alone. At a thirty-one-frame window spans only , and its velocity RMS error is , better than the nine-frame window at .
All the methods so far assume the motion changes little between neighbouring frames. If an oscillation is faster than the camera, the record itself misleads.
Shannon’s 1949 sampling theorem connects reconstruction to a known upper frequency limit. For a sinusoid of unknown phase, choose ; equality is unsafe. At exactly , , so a moving ball can disappear into an all-zero record. Above , frequencies can produce the same sampled positions as a lower frequency. This is aliasing. The theorem describes an ideal, indefinitely long record of a band-limited signal; a finite noisy video still leaves uncertainty.
The Lab's “Aliased motion” preset oscillates the ball at while the camera takes only 4 frames per second. In frame the sine is
The record is identical to that of a oscillation with the opposite sign. Velocities estimated from these frames have an RMS error of , while the true velocity amplitude is .
The “Stroboscopic rest” preset is more extreme: a oscillation filmed at 2 frames per second. Every frame lands on , so the ball seems not to move at all. In fact it passes the origin at every time a frame is taken, which is exactly the velocity error the Lab reports.
No derivative method can rescue this, because the information never entered the record. A useful check is to raise the frame rate and compare records. Even agreement between two rates needs a justified upper frequency limit before we can rule out faster hidden motion.
Chapter 1 showed that position is the starting position plus the integral of velocity over time. With one velocity estimate per frame, we can average the velocities of neighbouring frames, multiply by the frame interval and add up the pieces. This is the trapezoidal rule.
In such a sum, random errors are sometimes positive and sometimes negative, so they partly cancel. A constant velocity bias keeps accumulating instead. The “Velocity-bias drift” preset adds to every velocity estimate. Integration runs from the first valid estimate to the last, in all, so the integrated position ends ahead of the raw position by
That is exactly the Lab's Last segment integration minus raw position reading. The default nine-frame fit, with no bias added, gives only .
Another problem is a gap in the record. In the “Leaves the sensor” preset the ball runs out of the picture near the end, and only 114 of the 121 frames have a pixel. A nine-frame window that misses even one frame gives no estimate, so 106 velocity estimates remain. An honest estimator leaves those frames empty.
Below are the pixel columns of frames 13 to 17 in the Lab's default record, from to . Take , and . Find the three-point and five-frame velocity estimates at frame 15, and decide whether the difference between them is unusual.
| Frame | Pixel column | Position (m) |
|---|---|---|
| 13 | 1208 | 1.5333 |
| 14 | 1211 | 1.5583 |
| 15 | 1213 | 1.5750 |
| 16 | 1213 | 1.5750 |
| 17 | 1210 | 1.5500 |
First convert to positions; frame 13, for example, is at . Around these frames the ball reaches its furthest point to the right and starts back.
The three-point difference uses only frames 14 and 16:
In pixels, the two frames differ by 2 pixels; divided by 8 pixel seconds per metre, that is again .
The five-frame fit uses , with :
The two estimates differ by . The estimates share pixels, so their errors are correlated. Subtracting their pixel weights gives for three-point minus five-frame. With uncorrelated position noise of , the standard deviation of this difference is . The observed difference is about 1.5 such standard deviations, quite plausible under this noise approximation.
Finally, compare with the truth. From the formula in Section 2.2, the cosine term is zero at , so the true velocity is just the drift velocity, . The five-frame fit happens to hit it this time, and the three-point difference is high by less than one pixel's worth. A real experiment has no such truth, and you would rely on the kind of noise estimate in the previous paragraph to judge whether a result is reasonable.
Open the Motion Measurement and Numerical Differentiation Lab. A record has already been acquired when the page opens, and the readouts show the errors over the whole record. “Export raw pixels” saves the camera record, without the truth.
Compare derivative methods. Choose “Noisy oscillation”. Predict first: if you set “Derivative: 0 three points; 1 quadratic fit” to 0, will the velocity RMS error be larger or smaller than with the default nine-frame fit? Set it back to 1 and set “Quadratic fit window in frames” to 5, 15 and 31 in turn. Note the velocity and acceleration RMS errors and compare them with Table 2.1. Then set “Pixel noise bound before rounding” to 0 and “Integer pixel rounding” to 0. Which window's error hardly changes, and why?
Change the frame rate. Still with the three-point difference, raise “Frame rate” from 30 to 120. Before you do, use the formula in Section 2.5 to predict the new velocity error.
Check the calibration. Choose “Uniform motion”, set “Assumed scale error” to 10%, and note the raw position and velocity RMS errors. Press “Reset”, choose “Uniform motion” again, and this time set “Assumed origin pixel error” to 12. Explain why one error affects the velocity and the other does not.
Check the sampling. Choose “Aliased motion” and “Stroboscopic rest”. Use Section 2.7 to predict what the camera will see, then raise the frame rate step by step. Find the frame rate at which the record starts to follow the true motion and compare it with .
Table 2.3 collects the results for these settings. The Lab's perturbation and rounding are deterministic, so the same settings always give the same numbers. Changing Deterministic noise realization swaps in a different set of perturbations: across the 8 realizations we tried, the three-point velocity RMS error ranged from 0.059 to .
| Setting | Tracked frames | Raw position RMS error (m) | Velocity RMS error () |
|---|---|---|---|
| Noisy oscillation, three-point difference, frame rate 120 | 481 | 0.0031 | 0.264 |
| Noisy oscillation, nine-frame fit, frame rate 120 | 481 | 0.0031 | 0.042 |
| Uniform motion, assumed scale error 10% | 121 | 0.105 | 0.0455 |
| Uniform motion, assumed origin pixel error 12 | 121 | 0.100 | 0 |
| Aliased motion | 17 | 0 | 15.6 |
| Stroboscopic rest | 9 | 0 | 25.1 |
| Leaves the sensor | 114 | 0 | 0.069 |
A camera record gives the time and the pixel column of each frame. Positions need a calibration of scale and origin and depend on those assumptions. Velocities are computed from several positions and depend on the derivative method and the window. Both are estimates, with more sources of error than the raw record.
The two positions are and , so the average velocity is .
A wrong origin shifts both positions together and leaves the difference unchanged, so the velocity is still . A wrong scale changes the displacement in proportion. With a true scale of 190 pixels per metre, 50 pixels correspond to about and the velocity is about , so the original result is about 5% low.
From , the standard deviation is . The spread is a little larger than the offset, and neither can be ignored.
Three-point difference: .
A seven-frame fit has and , so . That is only the noise part. Seven frames span ; if the velocity changes noticeably in that time, smoothing adds a bias on top.
Substituting into the three-point difference gives , exactly the instantaneous velocity, so there is no truncation error.
For a sinusoid, the difference gives the true velocity times . For , the ratio falls from 1 toward zero as the frame interval grows. This attenuates the oscillating component; the constant drift is unchanged. With the default at , and the ratio is about 0.984, an underestimate of the oscillating amplitude of about 1.6%.
A higher frame rate means a shorter frame interval, which reduces truncation error and aliasing; in that sense it helps. But the three-point difference's noise grows like : four times the frame rate gives roughly four times the noise, and in the Lab the velocity error rises from to .
Widening the window in frames to cover about the same duration can use the extra samples to suppress independent noise. The motion must still be well approximated by a quadratic over that duration. The statement is true when position noise is very small, or when it is paired with a suitable fit window.
Between frames the fan turns of a turn, one full turn plus . The full turn is invisible, so in the video it advances only of a turn per frame and seems to turn slowly forwards at one turn per second. The rotation has been aliased to . If the fan has several identical blades, each blade moving into the next one's place also counts as a repeat, and the apparent speed changes again.
Treating the quoted tracking error as an uncorrelated standard deviation, the position noise is about . The three-point velocity noise is about , a third of the velocity itself and far too large.
Since the velocity changes little over , a window lasting about is reasonable: about 25 frames, . Then and the noise is about .
Ways to check: halve and double the window and see whether the shape of the velocity curve holds steady; film a motion known to be uniform and check that its velocity comes out flat; film a ruler to check the scale. A good answer may pick a different window, as long as it relates the window's duration to how quickly the motion changes and gives a noise estimate.
This chapter estimated velocity without prescribing the ball’s dynamical law. It still assumed a calibrated camera and sufficiently smooth motion within each fitting window. The next chapter takes a different route. It assumes the acceleration is constant, derives how position depends on time, tests that assumption against the whole record, and measures the acceleration of gravity.
Change one setting at a time, then compare what you see with the tables and answers in this chapter.
Motion Measurement & Numerical Differentiation →Record the pixel positions of a moving object with a simulated camera. Estimate velocity and acceleration with finite differences or a local fit, then see how noise, aliasing, calibration bias and integration drift affect the result.Instantaneous velocity as the limit of average velocity and as the derivative of position; speed as its magnitude.
Publication record checked. Cited as the standard reference for differentiating data with a moving local polynomial fit. The window formula in Chapter 2 is derived in the chapter.
Sampling-theorem section read on 2026-11-05 in the MIT-hosted scan (fab.cba.mit.edu/classes/S62.12/docs/Shannon_noise.pdf). Chapter 2 independently derives its alias examples and the zero-phase failure at exactly twice the sinusoid frequency; ideal reconstruction requires band limitation and an indefinitely long record.
Read 2026-11-05: uncertainty propagation includes covariance for correlated inputs. Chapter 2 derives the shared-pixel estimator contrast directly and treats uniform quantization noise as an approximation.
You are hereHow does a camera measure motion?
Interactive Physics Textbook · Reading path