Video and Motion: Background Subtraction and Optical Flow
A video is a stack of images, and everything in the previous lessons applies to each frame. What video adds is time: things move, and motion is information. A fixed traffic camera can find cars without knowing what a car looks like, just by noticing which pixels change; a drone can estimate its own movement from how the ground slides past. This lesson covers the two classic ways to measure motion, background subtraction (what is moving?) and optical flow (how is it moving?), on the course's synthetic traffic video and on a sample photograph, and prepares the tracking lesson.
Video as an array
A grey video is an array of shape , a colour video ; frame is video[t]. Real videos are stored compressed (H.264, H.265, AV1), and decoding, frame-rate conversion and sampling are covered in video preparation and image, audio and video data. Here the frames come from make_video, the course's generator: a 160 x 90 grey "road" with sensor noise and bright rectangles ("vehicles") driving at constant speed in three lanes, with the exact box of every vehicle in every frame as ground truth.
The frame rate (frames per second) sets how far things move between frames. An object with speed pixels per second moves
which matters for every method below: frame differencing needs large enough to see a change, optical flow needs it small (a few pixels), and trackers need it smaller than the gap between objects. Dropping frames to save compute multiplies . And sampling in time aliases like sampling in space: a wheel with 12 spokes turning at 2.4 revolutions per second, filmed at 24 frames per second, moves exactly 1.2 spokes per frame and appears to turn slowly forward; at 2 revolutions per second it seems to stand still, and just below that it seems to turn backwards (the "wagon-wheel effect").
Background subtraction
With a fixed camera, the background is what the scene looks like without moving objects, and the foreground mask is every pixel that differs from it by more than a threshold :
Everything depends on how the background is estimated:
| Method | Background | Typical failure |
|---|---|---|
| Frame differencing | the previous frame | uniform objects: only leading and trailing edges change |
| Running average | "ghosts" of objects present at the start, slow objects absorbed | |
| Temporal median | median of all (or the last ) frames, per pixel | needs every pixel to be background more than half the time; offline or delayed |
| Gaussian mixture (MOG2) | per pixel a mixture of up to 5 Gaussians, updated online | the learning rate trades adaptation against absorbing slow objects |
MOG2 (Zivkovic, 2004; Zivkovic and van der Heijden, 2006; after Stauffer and Grimson's 1999 mixture model) keeps for every pixel a few Gaussians over its grey values with weights; values explained by the heavy, narrow Gaussians are background. It copes with flickering leaves and lighting changes, and it can mark shadows (pixels darker by a constant factor) as a separate class. Here all four are scored against the ground-truth masks, frame by frame:
import numpy as np, cv2
cv2.setLogLevel(0)
def make_video(rng, n_frames=30, h=90, w=160, n_objects=3):
"""Grey road scene with bright rectangles ("vehicles") moving at constant velocity.
Returns frames (T, h, w) uint8 and gt: list per frame of (track_id, [x1, y1, x2, y2])."""
objs = []
for k in range(n_objects):
bw, bh = int(rng.integers(14, 24)), int(rng.integers(8, 14))
x, y = float(rng.uniform(0, w - bw)), float(10 + 25 * k + rng.uniform(0, 8))
vx = float(rng.choice([-1, 1]) * rng.uniform(1.5, 3.5)); vy = float(rng.uniform(-0.3, 0.3))
objs.append([x, y, bw, bh, vx, vy, int(rng.integers(170, 250))])
frames, gt = [], []
for t in range(n_frames):
f = rng.normal(60, 6, (h, w))
boxes = []
for k, (x, y, bw, bh, vx, vy, g) in enumerate(objs):
x1, y1 = int(round(x + vx * t)), int(round(y + vy * t))
if x1 + bw <= 0 or x1 >= w:
continue # left the frame
f[max(y1, 0):y1 + bh, max(x1, 0):x1 + bw] = g
boxes.append((k, [max(x1, 0), max(y1, 0), min(x1 + bw, w), min(y1 + bh, h)]))
frames.append(f.clip(0, 255).astype(np.uint8)); gt.append(boxes)
return np.array(frames), gt
def gt_mask(boxes, h=90, w=160):
m = np.zeros((h, w), bool)
for _, (x1, y1, x2, y2) in boxes:
m[y1:y2, x1:x2] = True
return m
def iou(a, b):
return (a & b).sum() / max((a | b).sum(), 1)
frames, gt = make_video(np.random.default_rng(0))
T = len(frames)
print("video:", frames.shape, frames.dtype, "| vehicles in frame 0:", len(gt[0]), "| in frame 29:", len(gt[-1]))
tau = 30 # grey levels; the noise has sigma 6
masks = {}
masks["frame difference"] = [np.abs(frames[t].astype(int) - frames[t - 1]) > tau for t in range(1, T)]
B, ra = frames[0].astype(float), []
for t in range(1, T):
ra.append(np.abs(frames[t] - B) > tau)
B = 0.95 * B + 0.05 * frames[t] # running average, alpha = 0.05
masks["running average"] = ra
med = np.median(frames, axis=0) # offline: uses the whole video
masks["median background"] = [np.abs(frames[t] - med) > tau for t in range(1, T)]
mog = cv2.createBackgroundSubtractorMOG2(history=30, varThreshold=16, detectShadows=False)
mg = [mog.apply(frames[t]) > 0 for t in range(T)]
masks["MOG2"] = mg[1:]
for name, ms in masks.items():
s = [iou(m, gt_mask(gt[t + 1])) for t, m in enumerate(ms)]
print(f"{name:18s} mean mask IoU: frames 1-29 {np.mean(s):.3f} | 1-5 {np.mean(s[:5]):.3f} | 20-29 {np.mean(s[19:]):.3f}")video: (30, 90, 160) uint8 | vehicles in frame 0: 3 | in frame 29: 1
frame difference mean mask IoU: frames 1-29 0.140 | 1-5 0.151 | 20-29 0.159
running average mean mask IoU: frames 1-29 0.294 | 1-5 0.319 | 20-29 0.204
median background mean mask IoU: frames 1-29 1.000 | 1-5 1.000 | 20-29 1.000
MOG2 mean mask IoU: frames 1-29 0.306 | 1-5 0.112 | 20-29 0.458
The ranking is extreme and instructive. Frame differencing scores a mask IoU of only 0.140: a vehicle is a uniform bright rectangle, so between two frames only the strips at its front and back change, and the inside, bright in both frames, looks static. This is the aperture problem in its simplest form. The running average starts from frame 0, which already contains the three vehicles, so they are baked into the background and leave ghosts at their starting positions; the vehicles are also slowly absorbed, and the IoU stays at 0.294. MOG2 with its default learning rate (about ) absorbs the uniform vehicles almost as fast as they arrive: 0.112 at the start, 0.458 late in the video. The temporal median is perfect (1.000), because every pixel shows the road in more than half of the 30 frames: each vehicle covers a given pixel for only about 7 frames. It is the right tool for offline analysis of a fixed camera, and impossible online.
Real scenes are harder for all four: lighting changes during the day, trees move in the wind, cameras shake, and cars stop at traffic lights for longer than half the window, becoming background for the median.
From a mask to boxes
A foreground mask becomes a detector with the steps of morphology and contours: an opening removes isolated noise pixels, a closing fills small holes, connected components turn each blob into an object, and a minimum area rejects specks. Scoring the boxes needs the detection-style matching by IoU (detection metrics): a box is a true positive if it overlaps a not-yet-matched vehicle with IoU at least 0.5.
import numpy as np, cv2
cv2.setLogLevel(0)
def make_video(rng, n_frames=30, h=90, w=160, n_objects=3):
"""Grey road scene with bright rectangles ("vehicles") moving at constant velocity.
Returns frames (T, h, w) uint8 and gt: list per frame of (track_id, [x1, y1, x2, y2])."""
objs = []
for k in range(n_objects):
bw, bh = int(rng.integers(14, 24)), int(rng.integers(8, 14))
x, y = float(rng.uniform(0, w - bw)), float(10 + 25 * k + rng.uniform(0, 8))
vx = float(rng.choice([-1, 1]) * rng.uniform(1.5, 3.5)); vy = float(rng.uniform(-0.3, 0.3))
objs.append([x, y, bw, bh, vx, vy, int(rng.integers(170, 250))])
frames, gt = [], []
for t in range(n_frames):
f = rng.normal(60, 6, (h, w))
boxes = []
for k, (x, y, bw, bh, vx, vy, g) in enumerate(objs):
x1, y1 = int(round(x + vx * t)), int(round(y + vy * t))
if x1 + bw <= 0 or x1 >= w:
continue # left the frame
f[max(y1, 0):y1 + bh, max(x1, 0):x1 + bw] = g
boxes.append((k, [max(x1, 0), max(y1, 0), min(x1 + bw, w), min(y1 + bh, h)]))
frames.append(f.clip(0, 255).astype(np.uint8)); gt.append(boxes)
return np.array(frames), gt
def blobs_to_boxes(mask, min_area=30):
"""Clean a foreground mask, then one box [x1, y1, x2, y2] per connected blob."""
m = cv2.morphologyEx(mask.astype(np.uint8), cv2.MORPH_OPEN, np.ones((3, 3), np.uint8))
m = cv2.morphologyEx(m, cv2.MORPH_CLOSE, np.ones((5, 5), np.uint8))
n, _, stats, _ = cv2.connectedComponentsWithStats(m)
return [[int(x), int(y), int(x + w), int(y + h)] for x, y, w, h, a in stats[1:] if a >= min_area]
def iou(a, b):
ix = max(0, min(a[2], b[2]) - max(a[0], b[0])); iy = max(0, min(a[3], b[3]) - max(a[1], b[1]))
inter = ix * iy
return inter / ((a[2] - a[0]) * (a[3] - a[1]) + (b[2] - b[0]) * (b[3] - b[1]) - inter)
def score(dets, gt, frames_used, thr=0.5):
"""Greedy matching per frame: TP, FP, FN summed over the frames."""
tp = fp = fn = 0
for t in frames_used:
g = [b for _, b in gt[t]]; used = set()
for d in dets[t]:
j = max(range(len(g)), key=lambda j: iou(d, g[j]), default=None)
if j is not None and j not in used and iou(d, g[j]) >= thr:
used.add(j); tp += 1
else:
fp += 1
fn += len(g) - len(used)
return tp, fp, fn
frames, gt = make_video(np.random.default_rng(0))
T = len(frames)
med = np.median(frames, axis=0)
mog_default = cv2.createBackgroundSubtractorMOG2(history=30, varThreshold=16, detectShadows=False)
mog_slow = cv2.createBackgroundSubtractorMOG2(history=30, varThreshold=16, detectShadows=False)
dets = {"frame difference": [[]], "median background": [], "MOG2 default rate": [], "MOG2 rate 0.01": []}
for t in range(T):
if t:
dets["frame difference"].append(blobs_to_boxes(np.abs(frames[t].astype(int) - frames[t - 1]) > 30))
dets["median background"].append(blobs_to_boxes(np.abs(frames[t] - med) > 30))
dets["MOG2 default rate"].append(blobs_to_boxes(mog_default.apply(frames[t]) > 0))
dets["MOG2 rate 0.01"].append(blobs_to_boxes(mog_slow.apply(frames[t], learningRate=0.01) > 0))
print("frame 10, truth: ", [b for _, b in gt[10]])
for name, d in dets.items():
print(f" {name:18s}", d[10])
for name, d in dets.items():
for frames_used, label in [(range(1, T), "1-29"), (range(10, T), "10-29")]:
tp, fp, fn = score(d, gt, frames_used)
print(f"{name:18s} frames {label:5s}: TP {tp:2d} FP {fp:3d} FN {fn:2d} precision {tp / max(tp + fp, 1):.3f} recall {tp / (tp + fn):.3f}")frame 10, truth: [[6, 13, 28, 24], [134, 36, 153, 47], [37, 66, 54, 79]]
frame difference [[6, 13, 9, 24], [28, 13, 31, 24], [131, 37, 134, 48], [150, 36, 153, 47], [34, 66, 37, 79], [51, 66, 54, 79]]
median background [[6, 13, 28, 24], [134, 36, 153, 47], [37, 66, 54, 79]]
MOG2 default rate [[6, 13, 12, 24], [147, 36, 153, 47], [48, 66, 54, 79]]
MOG2 rate 0.01 [[37, 10, 59, 21], [6, 13, 28, 24], [134, 36, 153, 47], [103, 39, 122, 50], [5, 66, 22, 79], [37, 66, 54, 79]]
frame difference frames 1-29 : TP 0 FP 119 FN 65 precision 0.000 recall 0.000
frame difference frames 10-29: TP 0 FP 65 FN 38 precision 0.000 recall 0.000
median background frames 1-29 : TP 64 FP 0 FN 1 precision 1.000 recall 0.985
median background frames 10-29: TP 37 FP 0 FN 1 precision 1.000 recall 0.974
MOG2 default rate frames 1-29 : TP 3 FP 69 FN 62 precision 0.042 recall 0.046
MOG2 default rate frames 10-29: TP 3 FP 25 FN 35 precision 0.107 recall 0.079
MOG2 rate 0.01 frames 1-29 : TP 49 FP 50 FN 16 precision 0.495 recall 0.754
MOG2 rate 0.01 frames 10-29: TP 37 FP 17 FN 1 precision 0.685 recall 0.974
Frame 10 shows each failure directly. Frame differencing produces two thin strips per vehicle (front and back), so six boxes and not one true positive in the whole video. MOG2 at the default rate reports only the newest part of each vehicle, the part that has not yet been absorbed. MOG2 with the slower rate 0.01 finds 37 of the 38 vehicle instances of frames 10 to 29 (recall 0.974), but also reports 17 false positives there and 50 over the whole video: the ghosts of the frame-0 vehicles, which a slow background takes long to forget (in frame 10 it still reports all three starting positions). The median background detects 64 of 65 vehicle instances with no false positive; its one miss, in frame 18, is a vehicle leaving the picture whose visible part is a 1-pixel sliver, below the 30-pixel minimum area.
So the learning rate is a real trade-off: fast adaptation forgets ghosts and lighting changes quickly but also swallows slow or stopped objects; slow adaptation keeps objects but keeps ghosts too. In deployment, a background model is usually started on frames without traffic, or MOG2 is run for a warm-up period before its output is used. Project 3 builds a full vehicle detector on this idea and measures it properly.
Optical flow
Background subtraction says where something moves. Optical flow estimates how: a displacement for every pixel (dense flow) or for chosen points (sparse flow). The starting point is brightness constancy: a point keeps its brightness as it moves, . For small a first-order Taylor expansion gives the optical flow constraint
with the spatial derivatives (Sobel, as in edge detection) and the temporal difference. That is one equation for two unknowns per pixel: only the flow component along the gradient is determined (the aperture problem: through a small hole, a moving straight edge looks the same whatever its motion along itself).
Lucas and Kanade (1981) assume that all pixels in a small window share one , which gives one equation per pixel and a least-squares problem:
is the structure tensor of the window, the same matrix as in the Harris corner detector (classical features). Both of its eigenvalues must be large for the system to be well conditioned: corners and textured patches can be tracked, flat regions (both eigenvalues small) and straight edges (one small) cannot. That is why sparse trackers pick corners to follow. The Taylor step is valid only for motions below about a pixel, so in practice Lucas-Kanade is iterated (warp the second image back by the current estimate, solve again) and run on an image pyramid (coarse levels see large motions as small ones). The least-squares geometry lesson covers the normal equations, and Taylor series the linearisation.
import numpy as np, cv2
from skimage import data
cv2.setLogLevel(0)
def shifted(img, dx, dy):
"""Move the image content by (dx, dy) pixels, sub-pixel, with bilinear interpolation."""
M = np.float32([[1, 0, dx], [0, 1, dy]])
return cv2.warpAffine(img, M, (img.shape[1], img.shape[0]), flags=cv2.INTER_LINEAR, borderMode=cv2.BORDER_REFLECT)
def lk_step(I0, I1, x, y, r=7):
"""One Lucas-Kanade step for the (2r + 1) x (2r + 1) window centred at (x, y)."""
Ix = (cv2.Sobel(I0, cv2.CV_64F, 1, 0, ksize=3) + cv2.Sobel(I1, cv2.CV_64F, 1, 0, ksize=3)) / 16 # Sobel / 8, averaged
Iy = (cv2.Sobel(I0, cv2.CV_64F, 0, 1, ksize=3) + cv2.Sobel(I1, cv2.CV_64F, 0, 1, ksize=3)) / 16
win = (slice(y - r, y + r + 1), slice(x - r, x + r + 1))
A = np.stack([Ix[win].ravel(), Iy[win].ravel()], 1)
b = -(I1 - I0)[win].ravel()
return np.linalg.solve(A.T @ A, A.T @ b), np.linalg.eigvalsh(A.T @ A)
def lucas_kanade(I0, I1, x, y, iters=1):
d = np.zeros(2)
for _ in range(iters): # warp I1 back by the estimate so far, solve for the rest
d += lk_step(I0, shifted(I1, -d[0], -d[1]), x, y)[0]
return d
cam = cv2.GaussianBlur(data.camera().astype(np.float64), (0, 0), 2) # smooth: LK's Taylor step needs it
for dx, dy in [(0.6, -0.3), (1.5, 1.0), (4.0, -3.0), (9.0, 6.0)]:
I1 = shifted(cam, dx, dy)
d1, d5 = lucas_kanade(cam, I1, 250, 200, 1), lucas_kanade(cam, I1, 250, 200, 5)
print(f"true ({dx:+.1f}, {dy:+.1f}) 1 step ({d1[0]:+.2f}, {d1[1]:+.2f}) 5 steps ({d5[0]:+.2f}, {d5[1]:+.2f})")
for name, (x, y) in [("textured window (250, 200)", (250, 200)), ("flat sky (60, 60)", (60, 60))]:
_, eig = lk_step(cam, shifted(cam, 1, 0), x, y)
print(f"eigenvalues of A^T A, {name}: {eig.round(3).tolist()}")true (+0.6, -0.3) 1 step (+0.65, -0.32) 5 steps (+0.71, -0.32)
true (+1.5, +1.0) 1 step (+1.53, +1.05) 5 steps (+1.65, +0.99)
true (+4.0, -3.0) 1 step (+4.25, -3.00) 5 steps (+4.01, -3.00)
true (+9.0, +6.0) 1 step (+5.88, -0.72) 5 steps (+9.01, +5.99)
eigenvalues of A^T A, textured window (250, 200): [1423.36, 2285.92]
eigenvalues of A^T A, flat sky (60, 60): [0.165, 1.932]
For a motion of a fraction of a pixel, one step is already close. At 4 pixels the single step is off by a quarter of a pixel and iterating fixes it; at (9, 6) the single step is useless (it even gets the sign of wrong) because the linearisation is far outside its range, and five iterations recover the motion to 0.01 pixel. Small residual errors of about 0.1 pixel for the small shifts come from the bilinear interpolation used to make (and undo) the shifts and from the derivative filters. The eigenvalues show why the window position matters: in the textured window both are over 1,000, in the flat sky the smaller one is about 0.2, and solving with it would amplify noise by a factor of thousands.
OpenCV's calcOpticalFlowPyrLK is the iterated, pyramidal version (Bouguet's implementation), usually fed with corners from goodFeaturesToTrack (the Shi-Tomasi criterion: the smaller eigenvalue of is large):
import numpy as np, cv2
from skimage import data
cv2.setLogLevel(0)
def shifted(img, dx, dy):
M = np.float32([[1, 0, dx], [0, 1, dy]])
return cv2.warpAffine(img, M, (img.shape[1], img.shape[0]), flags=cv2.INTER_LINEAR, borderMode=cv2.BORDER_REFLECT)
g0 = data.camera() # 512 x 512 grey, uint8
pts = cv2.goodFeaturesToTrack(g0, maxCorners=50, qualityLevel=0.01, minDistance=10)
print("corners to track:", len(pts))
for dx, dy in [(4, -3), (12, -8)]:
g1 = shifted(g0, dx, dy)
for levels in [0, 3]:
nxt, status, err = cv2.calcOpticalFlowPyrLK(g0, g1, pts, None, winSize=(15, 15), maxLevel=levels)
flow = (nxt - pts).reshape(-1, 2)
ok = status.ravel() == 1
right = ok & (np.hypot(flow[:, 0] - dx, flow[:, 1] - dy) < 0.5)
print(f"true ({dx:+d}, {dy:+d}), pyramid levels {levels}: {int(ok.sum())} reported tracked, "
f"{int(right.sum())} within 0.5 px, median flow ({np.median(flow[right, 0]):+.2f}, {np.median(flow[right, 1]):+.2f})")corners to track: 50
true (+4, -3), pyramid levels 0: 50 reported tracked, 47 within 0.5 px, median flow (+4.00, -3.00)
true (+4, -3), pyramid levels 3: 50 reported tracked, 50 within 0.5 px, median flow (+4.00, -3.00)
true (+12, -8), pyramid levels 0: 50 reported tracked, 15 within 0.5 px, median flow (+12.00, -8.00)
true (+12, -8), pyramid levels 3: 50 reported tracked, 50 within 0.5 px, median flow (+12.00, -8.00)
With a 15 x 15 window and no pyramid (maxLevel=0), a 5-pixel motion is still mostly fine (47 of 50 points within 0.5 pixel), but at (12, -8) only 15 of 50 points are right and the rest end up somewhere wrong, and status still says "tracked" for all of them: status 1 only means the point was not lost (it stayed inside the image and its window was well conditioned), not that the estimate is right. Three extra pyramid levels (maxLevel=3, each half the size of the one below) make the 14-pixel motion less than 2 pixels at the top level, and every point is right. In real use, check tracks with a forward-backward test (track from frame to and back; a correct point returns to where it started) and drop points with a large error.
Dense flow estimates a vector for every pixel: Farnebäck's method (2003; cv2.calcOpticalFlowFarneback, a polynomial fit per neighbourhood) classically, and learned networks such as RAFT (2020) today, which are far more accurate on large motions and textureless regions. Flow feeds video stabilisation, action recognition, frame interpolation and motion segmentation for moving cameras, where background subtraction fails.
Pitfalls
- A moving camera. Background subtraction assumes a fixed camera. For pan-tilt cameras, drones or phones, first estimate the camera motion (a homography from tracked corners, geometric transforms), warp, then subtract; or use a detector instead.
- Objects present at the start. Running averages and MOG2 learn them as background and report ghosts later (the false positives above).
- Stopped objects become background. A car waiting at a red light disappears from an adaptive model; trackers must remember it.
- Thresholds in grey levels. was chosen for noise with (5 standard deviations). Compressed real video has block artefacts and noise that varies with brightness; set thresholds from measured noise.
- Shadows and lighting. Moving shadows are foreground for a naive subtractor; MOG2's
detectShadows=Truemarks them as 127 instead of 255, so threshold at 255 to drop them. - Frame rate. Halving the frame rate doubles the motion per frame; recheck optical-flow window sizes and pyramid levels, and the tracker's gating, after any change in sampling (video preparation).
- Trusting
status. As shown, "tracked" is not correct; use forward-backward checks.
Practice
- A car drives at 15 m/s past a camera that sees 0.05 m per pixel at the car's distance. How many pixels per frame does it move at 30 fps and at 5 fps? Which one can pyramidal Lucas-Kanade with
maxLevel=3and a 15 x 15 window handle?
Answer
pixels per second. At 30 fps that is 10 pixels per frame, at 5 fps 60 pixels per frame. With three pyramid levels above the original (maxLevel=3) the top level is 8 times smaller: 10 pixels become 1.25 (easy), 60 pixels become 7.5 (at the edge of a 15 x 15 window, unreliable). At 5 fps a detector-based tracker is the safer choice.
- Why does frame differencing fail on the uniform rectangles of
make_video, and what would happen with a textured vehicle?
Answer
Between two frames, a pixel inside a uniform rectangle stays at the same grey value, so only the front strip (road becomes car) and the back strip (car becomes road) change, each to 3 pixels wide. A textured vehicle changes inside too, because the texture moves, so the difference mask fills in more, though still with holes where the texture is locally uniform.
- The temporal median background was perfect on this video. Construct a case where it fails.
Answer
Any pixel that is covered by objects in more than half of the frames: a car parked for the whole clip (it becomes background and is never detected), a queue of cars at a traffic light, or a slow, long truck. Also lighting that changes over the clip: the median then lies between the two lighting levels and either half of the clip is "foreground".
- In the Lucas-Kanade example, why is the image blurred with a Gaussian of first?
Answer
The Taylor expansion assumes the image is close to linear over the displacement. Blurring makes the image smoother, so the linear approximation holds over a larger displacement, and it averages out pixel noise in the derivatives. Pyramids push the same idea further: each level is blurred and halved.
Test yourself
A running-average background subtractor is started on a video whose first frame already contains three cars. What happens?
- Nothing, the cars are detected normally
- The cars are learned as background: when they drive away, their starting positions show up as false foreground (ghosts) until the average forgets them
- The video cannot be processed
- Only the third car is missed
The optical flow constraint gives one equation per pixel. What does Lucas-Kanade add to get a solution?
- A second camera
- The assumption that all pixels in a small window move together, giving an over-determined least-squares system
- A neural network
- The assumption that the image is flat
Why do sparse optical-flow trackers follow corners rather than points on a straight edge?
- Corners are brighter
- On a straight edge one eigenvalue of is near zero (the aperture problem), so motion along the edge cannot be measured; at a corner both are large
- Edges move faster
- Corners are rarer, which saves time
A video is sampled down from 30 fps to 10 fps to save compute. What changes for motion analysis?
- Nothing
- Every object moves 3 times as far between frames, so optical-flow windows, pyramid levels and tracker gates must be rechecked
- Objects move a third as far
- The colours change