matlab code object tracking using kalman filter
#1

pls give me the matlab code for moving object tracking with kalman filter
Reply
#2
I Want ppt of ball following robot so please give the ppt of ball following robot to me and this is helpful for me
Reply
#3
matlab code object tracking using kalman filter

Basic background of Kalman Filter:

The Kalman filter, also known as linear quadratic estimation (LQE), is an algorithm that uses a series of measurements observed over time, containing noise (random variations) and other inaccuracies, and produces estimates of unknown variables that tend to be more precise than those based on a single measurement alone. More formally, the Kalman filter operates recursively on streams of noisy input data to produce a statistically optimal estimate of the underlying system state. The filter is named for Rudolf (Rudy) E. Kálmán, one of the primary developers of its theory.

MATLAB CODE:

%See the below code update of 11/11/2014 for implementing the code through VideoReader instead of aviread. Now with this update you can solve many of your problems of using your own video for this code.

%Code in the Bold, & comments in normal font

clear all;
close all;
clc
%% Read video into MATLAB using aviread
video = aviread('rhinos.AVI');
%'n' for calculating the number of frames in the video file
n = length(video);
% Calculate the background image by averaging the first 10 images
temp = zeros(size(video(1).cdata));
[M,N] = size(temp(:,:,1));
for i = 1:10
temp = double(video(i).cdata) + temp;
end
imbkg = temp/10;
% Initialization step for Kalman Filter
centroidx = zeros(n,1);
centroidy = zeros(n,1);
predicted = zeros(n,4);
actual = zeros(n,4);
% % Initialize the Kalman filter parameters
% R - measurement noise,
% H - transform from measure to state
% Q - system noise,
% P - the status covarince matrix
% A - state transform matrix

R=[[0.2845,0.0045]',[0.0045,0.0455]'];
H=[[1,0]',[0,1]',[0,0]',[0,0]'];
Q=0.01*eye(4);
P = 100*eye(4);
dt=1;
A=[[1,0,0,0]',[0,1,0,0]',[dt,0,1,0]',[0,dt,0,1]'];
% loop over all image frames in the video
kfinit = 0;
th = 38;
for i=1:n
imshow(video(i).cdata);
hold on
imcurrent = double(video(i).cdata);

% Calculate the difference image to extract pixels with more than 40(threshold) change
diffimg = zeros(M,N);
diffimg = (abs(imcurrent(:,:,1)-imbkg(:,:,1))>th) ...
| (abs(imcurrent(:,:,2)-imbkg(:,:,2))>th) ...
| (abs(imcurrent(:,:,3)-imbkg(:,:,3))>th);
% Label the image and mark
labelimg = bwlabel(diffimg,4);
markimg = regionprops(labelimg,['basic']);
[MM,NN] = size(markimg);
% Do bubble sort (large to small) on regions in case there are more than 1
% The largest region is the object (1st one)
for nn = 1:MM
if markimg(nn).Area > markimg(1).Area
tmp = markimg(1);
markimg(1)= markimg(nn);
markimg(nn)= tmp;
end
end
% Get the upper-left corner, the measurement centroid and bounding window size
bb = markimg(1).BoundingBox;
xcorner = bb(1);
ycorner = bb(2);
xwidth = bb(3);
ywidth = bb(4);
cc = markimg(1).Centroid;
centroidx(i)= cc(1);
centroidy(i)= cc(2);
% Plot the rectangle of background subtraction algorithm -- blue
hold on
rectangle('Position',[xcorner ycorner xwidth ywidth],'EdgeColor','b');
hold on
plot(centroidx(i),centroidy(i), 'bx');
% Kalman window size
kalmanx = centroidx(i)- xcorner;
kalmany = centroidy(i)- ycorner;
if kfinit == 0
% Initialize the predicted centroid and volocity
predicted =[centroidx(i),centroidy(i),0,0]' ;
else
% Use the former state to predict the new centroid and volocity
predicted = A*actual(i-1,Smile';
end
kfinit = 1;
Ppre = A*P*A' + Q;
K = Ppre*H'/(H*Ppre*H'+R);
actual(i,Smile = (predicted + K*([centroidx(i),centroidy(i)]' - H*predicted))';
P = (eye(4)-K*H)*Ppre;
% Plot the tracking rectangle after Kalman filtering -- red
hold on
rectangle('Position',[(actual(i,1)-kalmanx) (actual(i,2)-kalmany) xwidth ywidth], 'EdgeColor', 'r','LineWidth',1.5);
hold on
plot(actual(i,1),actual(i,2), 'rx','LineWidth',1.5);
drawnow;
end

Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: object tracking in matlab ppt, scilab code for speech enhancement using kalman filter, kalman filter for inverted pendulum, object tracking and matlab code pdf, object tracking robot using 8051, object tracking and recognition using matlab program, tracking a object using sensors,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  how to calculate distance in heed protocol by using matlab 1 1,873 15-06-2018, 03:54 PM
Last Post: Guest
  program code of solar tracking system using 8051 microcontroller 6 23,202 03-05-2018, 09:30 PM
Last Post: Guest
  matlab code for incremental conductance mppt 1 1,415 02-05-2018, 02:28 PM
Last Post: eksi
  anomaly detection code in matlab 3 2,082 23-04-2018, 12:04 AM
Last Post: Guest
  vehicle tracking system project report 3 9,911 07-04-2018, 09:25 PM
Last Post: Guest
  matlab code for liver tumor segmentation 2 1,580 01-04-2018, 06:29 PM
Last Post: [email protected]
  matlab code for vehicle tracking using unscented kalman filter 3 16,724 26-03-2018, 08:57 PM
Last Post: fodayj
  matlab code for facial expression recognition using frequency domain 1 2,670 19-02-2018, 06:03 PM
Last Post: Guest
  ppt on design and implementation of intelligent campus security tracking system based on rfid and zigbee 7 15,960 09-02-2018, 02:20 PM
Last Post: udaya
  matlab code shadow detection and removal in colour images using matlab 2 2,243 12-01-2018, 01:24 PM
Last Post: dhanabhagya

Forum Jump: