370 likes | 591 Views
Stanford CS223B Computer Vision, Winter 2006 Lecture 7 Optical Flow. Optical Flow: Outline. Examples Formal definition, 1D case From 1D to 2D: Aperture Problem Course motion and pyramids. Optical Flow. * Picture from Khurram Hassan-Shafique CAP5415 Computer Vision 2003.
E N D
Stanford CS223B Computer Vision, Winter 2006Lecture 7 Optical Flow
Optical Flow: Outline • Examples • Formal definition, 1D case • From 1D to 2D: Aperture Problem • Course motion and pyramids
Optical Flow * Picture from Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Optical Flow: Outline • Examples • Formal definition, 1D case • From 1D to 2D: Aperture Problem • Course motion and pyramids • Flow Segmentation
Optical Flow Image tracking 3D computation Image sequence (single camera) Tracked sequence 3D structure + 3D trajectory
Optical Flow Velocity vectors Common assumption: The appearance of the image patches do not change (brightness constancy) What is Optical Flow?
Optical Flow Assumptions:Brightness Constancy * Slide from Michael Black, CS143 2003
Optical Flow Assumptions: * Slide from Michael Black, CS143 2003
Optical Flow Assumptions: * Slide from Michael Black, CS143 2003
{ Because no change in brightness with time Ix v It Optical Flow: 1D Case Brightness Constancy Assumption:
? Tracking in the 1D case:
Temporal derivative Spatial derivative Assumptions: • Brightness constancy • Small motion Tracking in the 1D case:
Temporal derivative at 2nd iteration Can keep the same estimate for spatial derivative Tracking in the 1D case: Iterating helps refining the velocity vector Converges in about 5 iterations
For all pixel of interest p: • Compute local image derivative at p: • Initialize velocity vector: • Repeat untilconvergence: • Compensate for current velocity vector: • Compute temporal derivative: • Update velocity vector: Requirements: • Need access to neighborhood pixels round p to compute • Need access to the second image patch, for velocity compensation: • The pixel data to be accessed in next image depends on current velocity estimate (bad?) • Compensation stage requires a bilinear interpolation (because v is not integer) • The image derivative needs to be kept in memory throughout the iteration process Algorithm for 1D tracking:
Optical Flow: Outline • Examples • Formal definition, 1D case • From 1D to 2D: Aperture Problem • Course motion and pyramids • Flow Segmentation
2D: From 1D to 2D tracking 1D: Shoot! One equation, two velocity (u,v) unknowns…
From 1D to 2D tracking We get at most “Normal Flow” – with one point we can only detect movement perpendicular to the brightness gradient. Solution is to take a patch of pixels Around the pixel of interest. * Slide from Michael Black, CS143 2003
How does this show up visually?Known as the “Aperture Problem”
Aperture Problem Exposed Motion along just an edge is ambiguous
From 1D to 2D tracking The Math is very similar: Window size here ~ 5x5 or 11x11
More Detail:Solving the aperture problem • How to get more equations for a pixel? • Basic idea: impose additional constraints • most common is to assume that the flow field is smooth locally • one method: pretend the pixel’s neighbors have the same (u,v) • If we use a 5x5 window, that gives us 25 equations per pixel! * From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Solution: solve least squares problem • minimum least squares solution given by solution (in d) of: • The summations are over all pixels in the K x K window • This technique was first proposed by Lukas & Kanade (1981) • described in Trucco & Verri reading Lukas-Kanade flow • Prob: we have more equations than unknowns * From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Conditions for solvability • Optimal (u, v) satisfies Lucas-Kanade equation • When is This Solvable? • ATA should be invertible • ATA should not be too small due to noise • eigenvalues l1 and l2 of ATA should not be too small • ATA should be well-conditioned • l1/ l2 should not be too large (l1 = larger eigenvalue) * From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Edge • large gradients, all the same • large l1, small l2 * From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Low texture region • gradients have small magnitude • small l1, small l2 * From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
High textured region • gradients are different, large magnitudes • large l1, large l2 * From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Observation • This is a two image problem BUT • Can measure sensitivity by just looking at one of the images! • This tells us which pixels are easy to track, which are hard • very useful later on when we do feature tracking... • Once suggestion: Track Harris Corners! * From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Optical Flow, Example Harris Corners David Stavens, Andrew Lookingbill, David Lieb (CS223B 2004)
Optical Flow, Example Optical flow David Stavens, Andrew Lookingbill, David Lieb (CS223B 2004)
Optical Flow: Outline • Examples • Formal definition, 1D case • From 1D to 2D: Aperture Problem • Course motion and pyramids
Revisiting the small motion assumption • Is this motion small enough? • Probably not—it’s much larger than one pixel (2nd order terms dominate) • How might we solve this problem? * From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
Reduce the resolution! * From Khurram Hassan-Shafique CAP5415 Computer Vision 2003
u=1.25 pixels u=2.5 pixels u=5 pixels u=10 pixels image It-1 image It-1 image I image I Gaussian pyramid of image It-1 Gaussian pyramid of image I Coarse-to-fine optical flow estimation
warp & upsample run iterative L-K . . . image J image It-1 image I image I Gaussian pyramid of image It-1 Gaussian pyramid of image I Coarse-to-fine optical flow estimation run iterative L-K