function makevideo_sampletracking(frames, wx, wy, filename, options)
options = argutil_setdefaults(options, 'marginx', [10, 10], 'marginy', [10, 10], 'side', ...
                              10);

[m, n, nFrame] = size(frames);

% random sample some points as the vertices of the mesh
[X, Y] = meshgrid(options.marginx(1)+1:options.side:n-options.marginx(2), ...
                  options.marginy(1)+1:options.side:m-options.marginy(2));
tracker_template = [X(:), Y(:)];
nTracker = size(tracker_template, 1);

tracker_template = round(tracker_template + randn(nTracker, 2) * 1);

trackers = zeros(nTracker, 2, nFrame);
trackers(:, :, 1) = tracker_template;
for i = 2:nFrame
    indices = sub2ind([m, n], tracker_template(:, 2), tracker_template(:, 1));
    thisWx = wx(:, :, i); 
    trackers(:, 1, i) = tracker_template(:, 1) + thisWx(indices);
    thisWy = wy(:, :, i); 
    trackers(:, 2, i) = tracker_template(:, 2) + thisWy(indices);
end;

tris = delaunay(tracker_template(:, 1), tracker_template(:, 2), {'QJ'});
options.mesh = tris;
%figure;
makevideo_anno(frames, trackers, filename, options);
