Tuesday, January 16, 2007

Real-Time Color Based Object Tracking



I have been trying to track moving objects for quite some time. I wasn't very successful in modifying my motion detection code to perform motion tracking because shadows were really making life difficult for my program. The program was having difficulties distinguishing the actual object from its shadow. So, I went for a different approach: "color based object tracking". Here's how it works. After the program captures an image from the webcam, it introduces it to a mean filter which causes the image to become blurred. This blurring is done to reduce noise from the image. After doing that, it uses an RGB filter to remove all objects from the image except the object to be tracked (I have to adjust the RGB filter manually for different objects). Then, to make life easier, the program thresholds the image. Thresholding turns the image into a 1-bit binary image. Check out the picture below:


Then, after performing some additional noise removal, it tries to determine the center of the object. See the picture below:


That's it! It's pretty simple, but I had to spend two days experimenting and testing this idea. Check out the video above to see this program tracking a yellow ball. I can't wait to hook this thing up with my floppy drive camera panner! It would be so much fun. :)

69 comments:

kernel_geek said...

Awesome

Anonymous said...

Great stuff!

Anonymous said...

Hi, I just found your blog and I really like the stuff you do. Things I wish I had time to try...
I was wondering if you ever release code and/or compiled programs?

Ashish Derhgawen said...

Glad you found my blog interesting. I release code on CodeProject whenever I feel that something is releasable..and sometimes I also release compiled apps with my posts. :)

Anonymous said...

I found you blog through hackaday
wow thats awesome will you be releasing source code for the object tracker?

Ashish Derhgawen said...

Hello there!

I won't be releasing the source for the object tracker right now. However, I will release it, after a few months.

Anonymous said...

It's been a few months now =)

How bout that source code?

This is too cool not to share!

Matthew said...

I agree..

this is really cool.

I'd be interested in the source as well.

Keep up the good work.

Anurag said...

grt job buddy.........
i was really stunned

i am doin my be project on this topic itself
can u help me with the coding part
my mail id is pratmicro_20@yahoo.co.in

pls send me the ckt diagram,h/w,s/w reqd along with the codes

Anurag said...

pls tell me the codes and h/w s/w reqd along with the ckt diagram

for this object detection and tracker
along with it pls tell me how to calculate distance from the object using laser

Anurag said...

pls tell me the codes and h/w s/w reqd along with the ckt diagram

for this object detection and tracker
along with it pls tell me how to calculate distance from the object using laser

yo2_sama said...

Yeah..definetely excellent program! Thanks for the help with the laser sketch man, our teacher got impressed with the final result, we just added some functionalities and that was it! The copyright thing remained untouched and we just added our names stating we added the functions. Thanks again Ashish

yo2_sama said...

yep..thanks again for the help man

Frigolit said...

Hey! Really neat app.
I found it while googling around cause I'm also working on building a object tracker using a webcam.
If possible I would like to take a look at the source code for your app.
So if you feel like it, drop me an e-mail at frigolit@gmail.com.
Thanks in advance :)

Anonymous said...

Can you send me the source code? I would like to do some experimenting with this.

paul.schowDNOSPAM@gmail.com

you have to remove DNOSPAM

Pedro Moreira said...

Hello Ashish,
I found your blog and I was astonished by your work capacity.

Have you released the source code yet?

If so, plz mail it to
pedro_silva_moreira@hotmail.com

If not, did you use matlab or did all image processing in c#?

Keep up the great work!!

hendrix said...

hi....ashish,
great job.........
i realy-realy interest to do about it
please sent me the source code

my email hendrixk4@gmail.com

thanks before......

ranjitha said...

hi
i am raga ranjitha.my b.tech project is the same as the one u r doing.please mail me ur code on color based object tracking.

raga said...

hi
Im ranjitha. my btech project is the same as the one you are doing. plz mail me ur code on colour based object tracking.

mike said...

hi ashish,
i can't describe how wonderfull your work seems!!
your project is my finall project at my college.. iv'e allready find a way of detecting objects' but not tracking one of them..
i'll be more than happy, if you can help me with the code..
my email is- mikeboussiba@gmail.com
thank's..
p.s.
now i'm seeing all your projects, and it's amaizing!!!

Anonymous said...

hi...thks...i m interested in this...can you pls send post up the source code?n what programming language you are using?thks...

Anonymous said...

hey i read through yor blog.. and it was very interesting .. i am doing another project simillar to yours.. i wonder if u could give me some guidance on the source code .. i'm planing to use vb on this project.. yor help will be very usefull for me ..u can mail the full source code on color based tracking to
vngdeadcell@hotmail.com

Antonio V. said...

Great project.
I am doing another simillar project , but in black and white.
Can you mail me the full source code on color tracking to
verdrive@hotmail.com

Thanks.

aLz said...
This post has been removed by the author.
Ashwin said...

Hey Ashish,
I am Ashwin Vijayakumar, an embedded systems entrepreneur and a robotics hobbyist. Nice blog you have maintained here. Off all your projects, this one (Object Tracker) impressed me a lot, the video clip demonstrates how smooth the algorithm works. Mind if I take a look at your source code? You can keep in touch with me at ashwin@afflatustechtronics.org

Martin said...

Nice Work! :)

Ashwin said...

Hey Ashish,
Can you kindly forward the source code for this application. I would love to work more on it.

Anonymous said...

Great project.

Can you mail me the full source code on color tracking to
saniclee@nate.com

Anonymous said...

Great project.

Can you mail me the full source code on color tracking to
saniclee@nate.com

Min Woo said...

Hello,

I am dying to experimenting with various ways to track objects using video stream such as this. Would you be able to send me the source code to this project so I can try out and see how this is done?

my email is:

loxics(AT)gmail.com

Thank you so much and I love following up on your projects. They are so fascinating!

-min

Anonymous said...

Hello there

i am doing my thesis project on this topic itself,can u help me with the coding part
my mail geraldermac@yahoo.com

pls send me the sourcecode along with the executable application

gerald

Fatih Demir said...

Hi,

My FYP is about real time color tracking.
Can please you mail me source code on color tracking.
Thanks.
eee.fatih.demir@gmail.com

Anonymous said...

Great job w/ everything. Ive got a few questions about the quality of the electronics and how it would affect the program's tracking ability.

manii.troll@gmail.com

Anonymous said...

Nice Job. I am also interested in tracking Moving car Number Plate. Could me send me the source code so that we both can work on this project. my email id is getbidyut@yahoo.co.in

Anonymous said...

wow its amazing

I'm also working on object tracking...but i'm still unable to get it to work.
can you please mail me your source code...it will help me a lot

pasindu.ed@gmail.com

thanks

Anonymous said...

It looks great! Can you send me the source-code? I neet to track some objects for a school-project! --> shout[(at)]gmx.ch

Thank you very much!

Anonymous said...

It looks great! Can you send me the source-code? I neet to track some objects for a school-project! --> shout[(at)]gmx.ch

Thank you very much!

Anonymous said...

Wow, it's really a nice program!
I'm very interested because my final highschoolproject is about tracking and correcting. Comparable with a self-targeting system. But we just can't figure out how to import a view from a webcam and use it to calculate te coordinates ( on the virtual x and y grid ) of the target! I hope you can help us and maybe send me te source...It's in C++ right?
svsoke@hotmail.com

Thanks in forward,
Stijn van Schooten

Anonymous said...

that is great, can you send me the code, I want to do some experiment like this. thank so much. my email address is : canminhhien@yahoo.com

manohar yadav said...

hi...........
u did superb.......
am also intrested in this one........
want to hav a look on coding part.....

plzzzz send me to manohar.meesala@gmail.com
........
.........
thanq

Anonymous said...

Ashish

I might have an application for this. If you are interested in some contract work, please email me at mrich29357@aol.com

Anonymous said...

Just wondering did you ever release source?

Anonymous said...

ashish,

I am doing a student project using object tracking. I could really use some direction in writing my software so I was wondering if you could send me the source code.

dsangree AT gmail.com

Thanks,

Dan

Anonymous said...

Hi Mr. Derhgawen, I really like your solution, can you tell me if the source code is available, i have a personal project at home i would like to implement.

I'll understand if you don't want to share your code.

my email is stephanemurphy at hotmail dot com
Thank you
Stephane

leo said...

Gud day ashish,

Im Leon. I have an electronincs engineering project w/c more than a half of its part is very similar to your "Motion Tracking" just using a common web cam. The Coordinates, X,Y axis of the Location of the object is my primary concern. I need like that computation of you'rs in finding the coordinates in order for me to make calculations to move a real lethal weapon such as real rifle mounted to turret composed of Servo Motors to move it Vertical and Horizontal such as X,Y axis. Im not realy enhanced to MATHLAB. I may need your Ideas to Succeed with my Engineering. You could be my best resource person. My Email is "tin_bends@yahoo.com" I would be proud if you could add me on you Yahoo Messenger.

If you are willing to share some Ideas on performing my project, please do me a message to my Email.

By the way I titled my project "WEAPON CONTROLLER: AN ALTERNATIVE CONTROLLING MACHINE PREPLACEMENT TO PHYSICAL ARMED WEAPON HANDLING " using VB .Net language for my software. Please help me.

Anonymous said...

can u mail me the information at venugpl10@gmail.com

Anonymous said...

Can i knows how you set your X and y which change with the movement of ball? Is it use any loop function?

Brijesh said...

hey could you please send me source code and documents related to it at birju.chokhra@gmail.com
it s ll be very help to me......
thanks in advance... [:)]

Anonymous said...

hey could you please send me the source code, am workin on a similar project. aedus17@gmail.com

Phong said...

Hi! I'm doing a project in Object tracking.I see your work very cool, awesome.:D
Can I see your code ? My email: tran.thanh.phong.09.01@gmail.com
Thank you very much.

Shung said...

Hello there~
It's so awesome. Actually I've been studying about this tracking system.
If possible please send me source code to study or release code on open source project site

Shung said...

oops.. sorry I forgot to left my email address.
see below :
koshung@gmail.com

Anonymous said...

Wow, increadable work as always.
I didn't see a link to your source code but I would like to get a copy of it please, bkearsons@gmail.com
Thank you.

akshay said...

hi job well done!!!
can u send me codes
akkirocks007@gmail.com

and yes i can send u some of the code i made

Anonymous said...

Hey, great program. i just started fumbling around in matlab to try to figure this out for use in a robotics project. I would greatly appreciate if you can send me some of that code to help me in the right direction

willdrum4food27@yahoo.com

thanks a lot

Anonymous said...

Hi

This is Parth from New Delhi. I really appreciate your work and think that it is really amazing to see how its working.
I have currently completed my 3rd year of computer engineering and was implementing a code which could use your code. In regard to the same, I request you to kindly email me your source code so that I can use a part of it. I will put your name in the acknowledgments and send you a copy of my project.

My email is parth.saxenaREMOVETHIS@gmail.com

Thanks

Anonymous said...

Hey could you please send me your source code

oke2119@yahoo.com

Anonymous said...

i realy interest to do about it. Can you send me the source code?
tokbali9@yahoo.de

Sebastian Böckmann said...

Hello,

nice work. I'm trying to do something like you did. So, could you please send the code to no1@boeckmann.org

Many thanks
Sebastian

sambha said...

Great bro,
Can you mail me the full source code on color tracking to
aeran.aabhas@gmail.com

sambha said...

Great bro,
Can you mail me the full source code on color tracking to
aeran.aabhas@gmail.com

Azif said...

Can U please send me the source code..My mail Id : aalisafa@gmail.com

rupali said...

hi!
u did superb!
m also intrested in the same.
can u plz help me in coding.
my id is roopdhabarde417@yahoo.co.in

Anonymous said...

congratulations! great stuff!

and... please also send me the source code to:

gt ät interad.at

:)
thanks a lot!!

Anonymous said...

hey buddy, what is really impressive. Im currently trying include vision tracking to a robot project i am undertaking and I would like get an idea. Could you plz forward your code to smilin_overlord@hotmail.com

thanks

Anonymous said...

Hey, could you send me the source code for this?
email- joe.prickett@gmail.com
it could really help with a high school project Im working on
thanks in advance

neteraser said...

me too please ! ! ! neteraser@list.ru =)

hEENa!!! said...

Hi Ashish,
I liked your blog a lot... andi need your help.I am trying to do similar work for my project,It would be great if I can have a psuedocode/algorithm/sourcecode.

My id is hrastogi@usc.edu...
looking fwd to ur reply

Blibot said...

Hi, could you send me the source code?
arezkiamine@hotmail.com