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.
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?
Every number in this chapter comes 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.
2.1 What the camera records
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. 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 .
2.2 The velocity of a sinusoidal motion
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 default motion's top speed is about . The ratio will return in Section 2.5, where it sets how much a difference underestimates the velocity.
2.3 Calibration: turning pixels into positions
If the camera scale is pixels per metre and the origin sits at column , then
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.
2.4 Summarising a list of errors
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 origin 12 pixels off, 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 unrelated errors add, the cross term averages to zero, so their standard deviations do not add directly: their squares do. 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, with a standard deviation of 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.
2.5 Differences: estimating velocity from neighbouring frames
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 a sinusoid, Section 2.2 already showed that the difference gives the true velocity times .
At , and the ratio is 0.99817. The velocity 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. Each of the two positions has an error with 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 .
2.6 Local fits: trading more frames for smoothness
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. 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.
- Reference
- Three-point
- Five-frame fit
- 31-frame fit
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 .
2.7 Sampling too sparsely: aliasing
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 showed in 1949 that a signal containing no frequencies above is completely determined by samples taken apart. The other side of the coin: at frame rate , an oscillation faster than masquerades in the record as a slower one. This is aliasing.
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. The only check is to raise the frame rate and see whether the record changes.
2.8 Integrating velocity back to position
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.
2.9 Worked example: velocity from five frames of pixels
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 . From Section 2.5, the three-point noise has a standard deviation of about and the five-frame fit about . The difference is within what noise allows and does not mean either calculation is wrong.
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.
2.10 Checking in the Motion Measurement Lab
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 |
2.11 Exercises
- Which quantities does a camera record give? Why are position and velocity both estimates?
- A camera has a scale of 200 pixels per metre with the origin at column 1024. A ball appears at column 1124 and then at column 1174, in two frames apart. Find the average velocity over that time. Does the answer change if the origin is really at column 1030? If the scale is really 190 pixels per metre?
- A set of errors has a mean of and an RMS of . What is the standard deviation? Is the set dominated by an overall offset or by spread?
- Position noise has a standard deviation of at . Roughly how large is the velocity noise of the three-point difference? Of a seven-frame fit?
- Use the result of Section 2.2 to show that the three-point difference has no truncation error for constant acceleration, and that for a sinusoidal oscillation it underestimates the velocity more at lower frame rates. At , by what percentage is the default motion's velocity underestimated?
- A classmate says, "The higher the frame rate, the more accurate the velocity." Use this chapter's results to say when this is true and when it is false.
- A fan turns 25 times a second. In a video at 24 frames per second, does it seem to turn slowly backwards or forwards, and how many turns per second does it seem to make?
- Transfer. You film a cart sliding across a table with a phone at 240 frames per second. The scale is about 1000 pixels per metre and the tracking error about 1 pixel. The cart moves at about and its velocity changes little over . How would you choose the derivative method and the window? Give the expected velocity noise and say how you would check that your choice is suitable.
2.12 Answers and explanations
Exercise 1
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.
Exercise 2
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.
Exercise 3
From , the standard deviation is . The spread is a little larger than the offset, and neither can be ignored.
Exercise 4
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.
Exercise 5
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 . The ratio is less than 1 and gets smaller as grows, so lower frame rates underestimate more. With the default at , and the ratio is about 0.984, an underestimate of about 1.6%.
Exercise 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 .
More frames turn into a smaller error only if the window is widened in frames so that it covers about the same time. The statement is true when position noise is very small, or when it is paired with a suitable fit window.
Exercise 7
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.
Exercise 8
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.
Next: testing a model with one fall
This chapter estimated velocity from a record without assuming any law for the motion. 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.
Figure and data notes
- The derivative of the sine and the error of the three-point difference are derived independently in this chapter. The definitions of average and instantaneous velocity follow OpenStax University Physics Volume 1, Section 3.2.
- Tables 2.1, 2.2 and 2.3 and Figure 2.1 were computed with the Motion Measurement Lab's model code at the Lab defaults: duration, frame rate, scale, pixel noise bound 0.5 pixels with rounding, deterministic noise realization 17. Other settings in the tables change only the parameters named. The reference velocity comes from the Lab's motion formula and is used only for comparison.
- The noise estimates in the text treat the Lab's deterministic perturbation as an even spread, to check orders of magnitude. They are not an exact description of the Lab's noise.
Test it in the Lab
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.Sources and reading scope
- OpenStax, University Physics Volume 1, §3.2 Instantaneous Velocity and Speed
Instantaneous velocity as the limit of average velocity and as the derivative of position; speed as its magnitude.
- A. Savitzky and M. J. E. Golay, Smoothing and Differentiation of Data by Simplified Least Squares Procedures, Analytical Chemistry 36(8), 1627–1639 (1964)
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.
- C. E. Shannon, Communication in the Presence of Noise, Proceedings of the IRE 37(1), 10–21 (1949)
Publication record checked. Cited for the sampling theorem. Chapter 2 uses only the elementary case it computes directly: a sine sampled at no more than twice its frequency can look like a slower motion.