Object Path Tracing Using MATLAB
PATH TRACING WITH IMAGE DIFFERENCE METHOD
The Image Processing Algorithm Used is called Image Differential which can be used to track moving objects.
The objective of video tracking is to associate target objects in consecutive video frames. The association can be especially difficult when the objects are moving fast relative to the frame rate. Another situation that increases the complexity of the problem is when the tracked object changes orientation over time. For these situations video tracking systems usually employ a motion model which describes how the image of the target might change for different possible motions of the object.
To perform video tracking an algorithm analyses sequential video frames and outputs the movement of targets between the frames. There are a variety of algorithms, each having strengths and weaknesses. Considering the intended use is important when choosing which algorithm to use. There are two major components of a visual tracking system: target representation and localization, as well as filtering and data association.
Target representation and localization is mostly a bottom-up process. These methods give a variety of tools for identifying the moving object. Locating and tracking the target object successfully is dependent on the algorithm. For example, using blob tracking is useful for identifying human movement because a person's profile changes dynamically. Typically the computational complexity for these algorithms is low. The following are some common target representation and localization algorithms:
· Kernel-based tracking (mean-shift tracking): an iterative localization procedure based on the maximization of a similarity measure (Bhattacharyya coefficient).
· Contour tracking: detection of object boundary (e.g. active contours or Condensation algorithm). Contour tracking methods iteratively evolve an initial contour initialized from the previous frame to its new position in the current frame. This approach to contour tracking directly evolves the contour by minimizing the contour energy using gradient descent.
The Algorithm we are using is called Image Differential. A static Background frame is subtracted from every subsequent frame. If there is a moving object then it is the only object which will remain and all other respective pixels will be eliminate that are constant.
The corresponding code:-
% Enter mycam+webcam in command window
img=snapshot(mycam);
for i=1:10
img=snapshot(mycam);
I1 = im2uint8(img);
img=snapshot(mycam);
I2=im2uint8(img);
pos1=I2-I1;
image(pos1)
[x,y] = ait_centroid(pos1) %this is a function file whose link has been mentioned
a(i)=x
b(i)=y
I1=I2;
img=snapshot(mycam);
I2 = im2uint8(img);
thisfig = figure();
thisax = axes('Parent', thisfig);
image(img, 'Parent', thisax);
title(thisax, sprintf('Frame #%d', i));
i
end
a
b
x=a
y=b
plot(x,y)
xx=input('value to be interpolated')
n=length(x);
if length(y)~=n,error('x & y must be of same length');
end
b(:,1)=y(:);
for j=2:n
for i=1:n-j+1
b(i,j)=(b(i+1,j-1)-b(i,j-1))/(x(i+j-1)-x(i))
end
end
xt=1;
yint=b(1,1);
for j=1:n-1
xt=xt*(xx-x(j));
yint=yint+b(i,j+1)*xt
end
This code implements an easiest possible way of path tracing through image difference method.
Good job.
ReplyDelete