Code covered by the BSD License  

Highlights from
Intellicam(Real time moving object tracker)

image thumbnail

Intellicam(Real time moving object tracker)

by

 

The above code used to track the real time moving objects

lokwebcamtrack.m
%Intellicam-Real time object tracking
% Create video input object. 
vid = videoinput('winvideo',1);
% Set video input object properties for this Intellicam project.
% Note that example uses both SET method and dot notation method.
set(vid,'TriggerRepeat',Inf);
vid.FrameGrabInterval = 5;
% Set value of a video source object property.
vid_src = getselectedsource(vid);
set(vid_src,'Tag','Intellicam setup');

% Create a figure window.
figure; 

% Start acquiring frames.
start(vid)
pause(2);
%pause helps the cam to adjust the lighting conditons
% Calculate difference image and display it.
while(vid.FramesAcquired<=1000) % Stop after 1000 frames
    data = getdata(vid,2); 
    %diff_im = data(:,:,:,1) - background;
    diff_im = imabsdiff(data(:,:,:,1),data(:,:,:,2));
    diff = rgb2gray(diff_im);
    %diff_range = rangefilt(diff);
    diff_bw = im2bw(diff,0.2);
    %ulta = imadjust(diff_bw,[0;1],[1;0]);
    bw2 = imfill(diff_bw,'holes');
    s  = regionprops(bw2, 'centroid');
    cd = s.Centroid
    centroids = cat(1, s.Centroid);
    imshow(data(:,:,:,2));
    %imshow(diff_bw)
    hold(imgca,'on');
    plot(imgca,centroids(:,1),centroids(:,2),'g*');
   %imshow(diff_bw);
   hold on;
   rectangle('Position',[cd 60 33],'LineWidth',2,'EdgeColor','b');
   hold(imgca,'off');
  
end

stop(vid)

Contact us