|
| Overview:
In this lab you will be handling video. You can use MATLAB's aviread function to load the movie clip, and movie to play it. In MATLAB, the movie is represented by a 3-dimensional array M(x,y,t) where t is the index for the video frame. You will be implementing some basic tracking techniques and well experimenting with optical flow. |
Data:
You can view Piere-Loui's lecture slides here
(http://www.lems.brown.edu/vision/courses/image-processing/tracking/tracking.htm)
|
| Problem 1:
Write a program to track the moving object in the Movie Clip A. (a) In the first image of the sequence - I(1), initialize the tracking region. This should be a rectangular region of length l and height h, represented by a point C(1), which is the upper left-hand corner of the region. Call this region of the image T(1). (b) For the next image in the sequence - I(2), or in general - I(n), pass T(n-1) over a square neighborhood of size M centered about the point C(n-1) in the image I(n) using a correlation function. The result should be an M*M array of correlation values. Visualize this array as either a (scaled) intensity image or as a 3D graph. From this you must determine the position of best correlation. This is your new point C(n). (c) Repeat step (b) for the remaining images of the sequence, coming up with a point C, for every frame. Now superimpose an lxh rectangle over each image I(n) at the location C(n). The rectangle should track the moving object. |
| Problem 2:
Given the values for {C(1),C(2),...,C(n)}, attempt to predict the location of C(n+1). Using the position of C(n) as well as previous values, com up with a parametric equation for position in x and y and use it to determine C(n+1). Try linear, 2nd and 3rd order prediction. For example: 2nd order: x(n) = a1 * n^2 + a2 * n + a3
Plug in values for C(n), C(n-1), and C(n-2) and solve the set of equations for a1,2,3 and b1,2,3. Then plug in n+1 to predict the location of C(n+1). Compare this with the actual value. You will need to recalculate the coefficients for every frame. Graph the error E(n). Which technique is best? Higher order prediction is more accurate, but there is a trade-off with calculation time. Also, why might you want to integrate prediction into a tracking system? |
| Problem 3:
Calculate the optical flow for every image in the movie. In optical flow, every pixel in a frame from a movie has a vector (u,v) that ideally represents the location of that pixel in the previous image. For example if part of an object in image I(n) was located at (x1,y1), and then moved to (x2,y2) in image I(n+1), then the vector at point (x2,y2) in image I(n+1) would be (u,v) = ([x2-x1],[y2-y1]). Refer to the Optical Flow handout for the equations to calculate these vectors for each image (Trucco & Verri pp. 196-197 -- PDF above). Try it out on Movie Clips A and B. Matlab has a function for displaying vector fields. Display the optical flow for a few frames of both movie clips and comment on how they represent the movement in the image. Now use the optical flow motion field to create a tracking system.
Initialize a rerion on the first image of the sequence and use the local
vector field to update the position (dX,dY). It will probably take
some calibration.
|
| Problem 4:
Compare the two techniques and comment on the advantages and disadvantages. |