You are on page 1of 6

De La Salle University

College of Engineering
Electronics and Communication Engineering

Project Title : Object Path Tracking and Object


Detection

Date Submitted : August 14, 2006

Instructor : Engr. Edwin Sybingco

Subject / Section : SIGSLAB / EK1

Group Members : Anthony A. Arcellana


Warren S. Ching
Marvin Santos
Jonathan So
Abstract

The project used MATLAB to detect the moving object


and at the same time track the path the object has taken.
The group used a round object that is moving and used the
centroid as the reference point to track the object.
Functions in MATLAB were used to detect and filter the
object. The conducted experiment was successful although
when the round object was out of the boundary and the round
object was not round anymore, the computed centroid was
incorrect so the path detected was incorrect. The group
also chose a black background to make it simpler.

Introduction

Image processing is any form of information processing


for which both the input and output are images. Most image
processing involves treating a 2-D image signal and
applying standard signal processing to it. Applications
involving image processing is now increasing and one of the
famous application involving image processing is computer
vision. Most application relating image processing involves
object detection which specifies the location of the object
in the image and some could recognize the shape of the
detected object. Several techniques can be used for
detecting objects in an image or video and there is no
superior technique. It depends on the application which
technique will provide a better result. Some of the
commonly used techniques were background subtraction, image
thresholding and Hough Transform. Object path tracking
involves detecting the direction of the object/s in motion
with respect to several images. This application is
commonly used when involving video/s as input. Tracking is
important in examining the behavior of the object to be
studied. Combining the two mention tools will yield a
powerful tool for analyzing and studying behavior of the
subject in an image or video.

Theoretical Framework

The function find was used to find the object with


respect to the threshold. Mean was used to determine the
centroid of the round object. These are used as reference
points to where the object is at different instances.
Converting the images to gray using the function
rgd2gray was the first step to detect the object. Im2bw was
also used to convert it further to black and white to make
the image a binary image. After detecting the object,
bwareopen was used to remove unnecessary objects captured.
Further filtering functions was used to remove other noises
present. These functions include strel, imclose and not.

Source Code

%-------------MOTION PATH x2 = round(mean(x2));


DETECTION----------------------- y2 = round(mean(y2));
clear all;clc; x3 = round(mean(x3));
%load images y3 = round(mean(y3));
circ1=imread('circ1.jpg'); x4 = round(mean(x4));
circ2=imread('circ2.jpg'); y4 = round(mean(y4));
circ3=imread('circ3.jpg'); x5 = round(mean(x5));
circ4=imread('circ4.jpg'); y5 = round(mean(y5));
circ5=imread('circ5.jpg'); x6 = round(mean(x6));
circ6=imread('circ6.jpg'); y6 = round(mean(y6));
circ7=imread('circ7.jpg'); x7 = round(mean(x7));
circ8=imread('circ8.jpg'); y7 = round(mean(y7));
x8 = round(mean(x8));
%set image reference / y8 = round(mean(y8));
threshold
Ia_white1=uint8(circ1(:,:,1)<63&c figure(1);
irc1(:,:,2)>72&circ1(:,:,3)<67); imshow(circ1); hold on;
Ia_white2=uint8(circ2(:,:,1)<63&c imshow(circ2); hold on;
irc2(:,:,2)>72&circ2(:,:,3)<67); imshow(circ3); hold on;
Ia_white3=uint8(circ3(:,:,1)<63&c imshow(circ4); hold on;
irc3(:,:,2)>72&circ3(:,:,3)<67); imshow(circ5); hold on;
Ia_white4=uint8(circ4(:,:,1)<63&c imshow(circ6); hold on;
irc4(:,:,2)>72&circ4(:,:,3)<67); imshow(circ7); hold on;
Ia_white5=uint8(circ5(:,:,1)<63&c imshow(circ8); hold on;
irc5(:,:,2)>72&circ5(:,:,3)<67); alpha(.2);
Ia_white6=uint8(circ6(:,:,1)<63&c
irc6(:,:,2)>72&circ6(:,:,3)<67); %plotting of detected
Ia_white7=uint8(circ7(:,:,1)<63&c centroids
irc7(:,:,2)>72&circ7(:,:,3)<67); plot(x1,y1,'r*');
Ia_white8=uint8(circ8(:,:,1)<63&c plot(x2,y2,'ro');
irc8(:,:,2)>72&circ8(:,:,3)<67); plot(x3,y3,'r*');
plot(x4,y4,'ro');
%finding the object with plot(x5,y5,'r*');
respect to the threshold color plot(x6,y6,'ro');
[y1,x1] = find(Ia_white1==1); plot(x7,y7,'r*');
[y2,x2] = find(Ia_white2==1); plot(x8,y8,'ro');
[y3,x3] = find(Ia_white3==1);
[y4,x4] = find(Ia_white4==1); %interconnecting centroids
[y5,x5] = find(Ia_white5==1); plot([x1,x2],[y1,y2]);
[y6,x6] = find(Ia_white6==1); plot([x2,x3],[y2,y3]);
[y7,x7] = find(Ia_white7==1); plot([x3,x4],[y3,y4]);
[y8,x8] = find(Ia_white8==1); plot([x4,x5],[y4,y5]);
plot([x5,x6],[y5,y6]);
%c. Find the centroid of the plot([x6,x7],[y6,y7]);
object plot([x7,x8],[y7,y8]);

x1 = round(mean(x1)); %---------OBJECT
y1 = round(mean(y1)); DETECTION-------------
bw6 = bwareaopen(B6,2000);
bw7 = bwareaopen(B7,2000);
%threshold the image file bw8 = bwareaopen(B8,2000);
G1 = rgb2gray(circ1);
imthr1 = graythresh(G1); % fill gaps
B1 = im2bw(G1,imthr1); se = strel('disk',2);

G2 = rgb2gray(circ2); bwa = imclose(bw1,se);


imthr2 = graythresh(G2); bwb = imclose(bw2,se);
B2 = im2bw(G2,imthr2); bwc = imclose(bw3,se);
bwd = imclose(bw4,se);
G3 = rgb2gray(circ3); bwe = imclose(bw5,se);
imthr3 = graythresh(G3); bwf = imclose(bw6,se);
B3 = im2bw(G3,imthr3); bwg = imclose(bw7,se);
bwh = imclose(bw8,se);
G4 = rgb2gray(circ4);
imthr4 = graythresh(G4); % fill holes
B4 = im2bw(G4,imthr4); Bw1 = not(imfill(bwa,'holes'));
Bw2 = not(imfill(bwb,'holes'));
G5 = rgb2gray(circ5); Bw3 = not(imfill(bwc,'holes'));
imthr5 = graythresh(G5); Bw4 = not(imfill(bwd,'holes'));
B5 = im2bw(G5,imthr5); Bw5 = not(imfill(bwe,'holes'));
Bw6 = not(imfill(bwf,'holes'));
G6 = rgb2gray(circ6); Bw7 = not(imfill(bwg,'holes'));
imthr6 = graythresh(G6); Bw8 = not(imfill(bwh,'holes'));
B6 = im2bw(G6,imthr6);
figure(2);subplot(241);imshow(Bw1
G7 = rgb2gray(circ7); );
imthr7 = graythresh(G7); subplot(242);imshow(Bw2
B7 = im2bw(G7,imthr7); );
subplot(243);imshow(Bw3
G8 = rgb2gray(circ8); );
imthr8 = graythresh(G8); subplot(244);imshow(Bw4
B8 = im2bw(G8,imthr8); );
subplot(245);imshow(Bw5
);
% remove all object containing subplot(246);imshow(Bw6
fewer than 2000 pixels );
bw1 = bwareaopen(B1,2000); subplot(247);imshow(Bw7
bw2 = bwareaopen(B2,2000); );
bw3 = bwareaopen(B3,2000); subplot(248);imshow(Bw8
bw4 = bwareaopen(B4,2000); ); title ('holes removed');
bw5 = bwareaopen(B5,2000);

Experimental Set-up

We first acquired images of a moving object using a pc


camera. Then we set threshold values of the acquired images
which we will use as a reference for detecting the object
since our object detection uses threshold color in finding
objects. Then we stored the detected image in 2-D array.
The specific object we used was a circular lid of a can. We
determine the mean of the detected object, and a round
object has a mean at the center we were able to detect the
center of the can lid. We were able to track the path by
connecting the centers detected in the inputted images.

Data and Results

Captured image with the tracked path

The detected object in eight frames

Analysis of Data
Based on our gathered date, the object in the images
has successfully been detected. The path taken by the
object has also been detected. Although, in the last frame,
the object exceeded the boundary of the view of the camera
making the round object does not seem like round anymore.
MATLAB was not able to compute for the centroid, so the
detected path in the eighth frame was wrong.

Conclusion

We can conclude that the algorithms and method used


for object detection and object path tracking was
successful in their objective as long as not to exceed the
limitations that are discussed and mentioned above. The
project required researching for different codes and syntax
but was simple enough to discover. The project was done to
merely demonstrate object detection and tracking therefore
we can improve on this depending on the requirements needed
by the application. Limitations can be eliminated thus
improving the quality of the output.

Reference

http://www.mathworks.com/matlabcentral/link_exchange/MATLAB
/Image_Processing/index.html

http://en.wikipedia.org/wiki/Image_processing

You might also like