Code covered by the BSD License  

Highlights from
Particle Filter Color Tracker

4.72222

4.7 | 20 ratings Rate this file 107 Downloads (last 30 days) File Size: 12.5 MB File ID: #17960
image thumbnail

Particle Filter Color Tracker

by

 

11 Dec 2007 (Updated )

Tracking an object in a video with a Color Particle Filter

| Watch this File

File Information
Description

A simple example demonstrating how to track an object with particle filter. Likelihood function is based on Bhattacharya distance of color histograms and gradient distributions

Please run mexme_pf_color_tracker to recompile mex-files on your own plateform.

Run the two demo files test_pf_colortracker and test_pf_colortracker2

IMPORTANT. Be sure than you "mex -setup" had been done before compiling sources

MATLAB release MATLAB 7.5 (R2007b)
Other requirements A C Compiler such MSVC/Intel CPP/GCC
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (78)
27 Mar 2014 Ahmad  
26 Mar 2014 Ahmad

The desperation worked out at last ... I only Uncommented the pdfgrad_ellipse function with a threshold_grad in the input list (which was by default commented) AND I Commented the pdfgrad_ellipse function without threshold_grad in its input list .... my statement might be confusing so have a look at the 2 functions that were played with ....

likelihood_shape = pdfgrad_ellipse(Z , yk , ek , h0 , lambda , sigma_shape , l , alpha0 , ratio , bary , nb_classe , threshold_grad);

% likelihood_shape = pdfgrad_ellipse(Z , yk , ek , h0 , lambda , sigma_shape , l , alpha0 , ratio , bary , nb_classe);

26 Mar 2014 payal

Thanks a lot for sharing this code...
Thanks Ravi Prakash, without settings you mentioned I was unable to do it...
Thanks a lot...

26 Mar 2014 payal  
25 Mar 2014 Sebastien PARIS

Ahmad,

Did you recompile mex files for your system ? (run mexme_ ....).
What is your exact OS ?, compiler ?

25 Mar 2014 Ahmad

Sir, I mean test_pf_colortracker is tracking fantastic BUT the test_pf_colortracker2 is making the trouble ... and I have used BREAKs in my code (I mean your code :)) .. and I have identified the error making function which is the pdfgrad_ellipse ....
Thank you very much sir for the quick response .

25 Mar 2014 Sebastien PARIS

Ahmad,

What do you mean by "the second part of the code" ? Does the tracking is well displayed ?

25 Mar 2014 Ahmad

Thank you Sebastein for sharing this code, I am having problems with the 2nd part of the code. Matlab forces me to restart it, am I doing something wrong.
Configuration of my systems are:
core-i5, 4 GB RAM, Windows 7 Home edition, SDK 7.1 installed, MatLab 8.2.0.701 (R2013b) .... Sir, can you look into this issue please. I shall be thankful Sir, Regards

17 Jan 2014 Sebastien PARIS

Jae,

Please find informations in:

X. Rong Li et V. P. Jilkov : Survey of maneuvering target tracking. Part I. Dynamic models.
Aerospace and Electronic Systems, IEEE Transactions on, 39(4):1333–1364, 2003.

12 Jan 2014 Jae Hyuck

Firstly, thank you for this excellent program.
While analyzing this program, I got a question.

When you construct motion model covariance matrix for pos and vel, R_y, you consider them as dependent(not using diagonal matrix) as a relation with delta_k. Could you give me some evidence why you select such model?
% R_y = sigma_y |delta_k^3/3 delta_k^2/2|
|delta_k^2/2 delta_k|

11 Jan 2014 Stendo

Sebastien,
You know how it doing ?

10 Jan 2014 Sebastien PARIS

Stendo,

You must define a model of likelihood given your geometric model of your object... and plug into this code

10 Jan 2014 Stendo

Hi please help me.I would need to modify this project. I need to recognize objects using geometric properties or edge recognition. It must be particle filter. I am a beginner in MATLAB and I do not know how to do. Thanks for helping
s.bogdan@pobox.sk

01 Jan 2014 daher

Hi all
I am having an inquiry. Suppose i have to track the first blue color object found in a video. After few frames, another object with the same color appears. How to keep tracking the first object no matte what will appear in the video without referring to the geometry of each blue object and compare it with the first identified. Hope you can give me a hint... Thaaaaaanks

27 Sep 2013 Ricardo

Excellent, thank you. Still have to fully understand the theory though :)

Users of Linux hope this helps: video_file should be set to the full path, e.g. '/opt/matlab/.../SECOND.AVI', and have gstreamer0.10 plugins installed.

If you do not have mmreader, check out mmread from fileexchange. mmread does not instantiate a class, it returns a struct and therefore all set, get, read in the original test files should be replaced to access struct members.

ln38:
video = mmread(video_file);
nb_frame = video.nrFramesTotal - offset_frame - 10;
dim_x = video.width;
dim_y = video.height;

ln127 : I = video.frames(offset_frame + 1).cdata;
ln158 : I = video.frames(offset_frame + k).cdata;

16 Aug 2013 Dasar Sisten Kontrol

i get problem with file download. can you help me for send me the file at my email please? vitalokaa@yahoo.com

15 Aug 2013 Dasar Sisten Kontrol  
12 Apr 2013 balaji

thanku sir..

18 Mar 2013 Sebastien PARIS

K Nummiaro, E Koller-Meier, L Van Gool, An adaptive color-based particle filter, Image and Vision Computing, 2003 - Elsevier

for example

14 Mar 2013 balaji

sir i need some details about this pf colour tracker..any reference paper about this example?

30 Jan 2013 Karthik MSwamy

Excellent code. Works perfect on my Win 8, Matlab 2011b x64. Can you please cite the paper you used for writing this tracker?

28 Jan 2013 GITAM

waiting for u r valuable reply

08 Jun 2012 ECE

cool

16 Mar 2012 sahere rahimi

i do not have any c compiler, please help me, please give me a file that does'nt need any c compiler

15 Mar 2012 Sebastien PARIS

Ching-Chun: 2009b win64 ?
Can you put a break point to stop at errors ?

10 Mar 2012 Ching-Chun

I change the matlab version to 2009b, however the error still occurs. I hope I can help to repair the bug, but there is no more information.

05 Mar 2012 Sebastien PARIS

The problem ... that I don't know from which mex-files, the crash is coming....
Do you have more verbose ?

05 Mar 2012 Ching-Chun

sorry, I forgot to mention these. My Os is windows 7 64-bit, processor is Intel Core 2 Duo 2.80 GHz, Matlab version is 7.6.0.324 (R2008a), and the used compiler is Microsoft Visual Studio 2010.

05 Mar 2012 Sebastien PARIS

What is excetly your system ? OS, processor, version of Matlab, compiler used ?

05 Mar 2012 Ching-Chun

Sebastien Paris, thank you. The program works well now. But when I run "test_pf_colortracker2.m", there are some errors and then Matlab asks to restart. Is it because I do somethin wrong? The followed are excerpts from the error messages:

...
Frames = 106/770
Frames = 107/770
Saving minidump to file C:\Users\irene\AppData\Local\Temp\matlab_crash_dump.4692.0.dmp

------------------------------------------------------------------------
Segmentation violation detected at Mon Mar 05 15:20:34 2012
------------------------------------------------------------------------

Configuration:
MATLAB Version: 7.6.0.324 (R2008a)
MATLAB License: 161051
Operating System: Microsoft Windows Vista
Window System: Version 6.1 (Build 7601: Service Pack 1)
Processor ID: x86 Family 6 Model 7 Stepping 10, GenuineIntel
Virtual Machine: Java 1.6.0 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode
Default Encoding: Big5

Fault Count: 1

Register State:
rax = 00000000ffffffff rbx = 0000000000000028
rcx = 000000000000ef53 rdx = 0000000000000011
rbp = 0000000000000029 rsi = 0000000000001d3b
rdi = 00000000354f5cd0 rsp = 000000000102bc00
r8 = 0000000000000000 r9 = 0000000000000028
r10 = 000000003547e228 r11 = 0000000000000028
r12 = 000000000000000b r13 = 000000003da57e00
r14 = 0000000000000000 r15 = 00000000000000fa
rip = 000007fef8291c93 flg = 0000000000010203

Stack Trace:

This error was detected while a MEX-file was running. If the MEX-file
is not an official MathWorks function, please examine its source code
for errors. Please consult the External Interfaces Guide for information
on debugging MEX-files.

... ...

04 Mar 2012 Sebastien PARIS

Ching-Chun. As indicaded in requierements, you must have C compiler. Please install for example Visual C++ express accoding to your version of Matlab.

02 Mar 2012 Ching-Chun

Please help me.
What should I do to make it works?

When I compile the file "mexme_pf_color_tracker.m"
I got the messages

echo on

mex

Select a compiler:

[0] None

Compiler:

If I enter "0", I got more messages as follows.

mex: No compiler selected. No action taken.

**************************************************************************
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the new
API. You can find more information about this at:
http://www.mathworks.com/support/solutions/data/1-5C27B9.html?solution=1-5C27B9
Building with the -largeArrayDims option enables the new API.
**************************************************************************


C:\PROGRA~1\MATLAB\R2008A\BIN\MEX.PL: Error: No compiler options file could be found to compile source code. Please run "mex -setup" to rectify.

??? Error using ==> mex at 207
Unable to complete successfully.

Error in ==> mexme_pf_color_tracker at 3
mex

15 Dec 2011 zhao

Hi Sebastien,i modified the files,and Create more problems. If i want to run the files in matlab7.0, can you sent the right files to me. My email:happyday.huihuang@gmail.com,thanks a lots.

15 Dec 2011 Sebastien PARIS

Zhao,

Instead of badly rating, please have the nominal configuration requiered.

14 Dec 2011 zhao  
14 Dec 2011 zhao

My matlab7.0 can not find function 'mmreader'. If aviread is used,can tell me where should be replace in the files.
thanks

21 Sep 2011 Sathiyaraj Manoharan

Can anyone explain me how to install the C compiler and compile the C files in MATLAB..

20 Sep 2011 Sathiyaraj Manoharan

Hi Sebastien:
I am new to this can you explain how to execute.I m getting error like C file is not found.I think that because of the mex compiler. how to install that with brief.Is it necessary to install VC++ 2008 express.Can I run it in Matlab2011.

16 Sep 2011 Chi Chin

Hi Sebastien,

Thanks for your prompt reply. I had installed the K-lite mega codec in my system but it still give me the same error :<

16 Sep 2011 Sebastien PARIS

Chi,

Maybe install a video codec pack such K-lite mega codec in your system. Regards,

16 Sep 2011 Chi Chin

I get the following error on Windows 7(64-bit) and MATLAB R2009b. Can anyone assist?

??? Error using ==> aviread at 76
Unable to locate decompressor to decompress video stream

Error in ==> test_pf_colortracker at 196
mov = aviread(video , offset_frame + 1);

anyone can help me?

18 Jul 2011 Selva

Thanks for sharing dude..

21 May 2011 Sebastien PARIS

oj: If I have time, I'll update with mmreader instead of the old (and depreciated) aviread

21 May 2011 Sebastien PARIS

Jake: here IS used here is independant of the current measure so ... q(x_k|x_{k-1},z_k) = p(x_k|x_{k-1}) here ...

20 May 2011 oj

Dear sebastien I am unable to get the program in running condition... Even though I have replaced mmreader for aviread... still cudnt fix problem... help anyone..

03 May 2011 Jake

Thank you for sharing, I just wondering did you pick a importance density in this program?

20 Mar 2011 Sebastien PARIS

to kar: as we say in french "pour avoir le beurre et l'argent du beurre".... in other words, the easiness of matlab and the speed of C.

18 Mar 2011 tejaswini kar

sir can i get the reference material of the codes for my work.actually i am unable to understand it.is it possible that either the whole program can be written in matlab or written in c.why u have used both c an matlab. what is the advantage.

25 Jan 2011 Kevin Murphy  
04 Jul 2010 tarun goel

Hi sir, it is indeed a nice work and thanx for sharing it. Could you please tell some refeence material where the meaning of variables can be understood as their names are of little help. Iwud be highly thankful.

13 Jun 2010 Duy Nguyen  
11 Jun 2010 Duy Nguyen

Thank for your sharing, Sebastien. I want to get more detail about this issue, can you give me reference for this ones.

03 Sep 2009 Hong 4

I found a paper relates to this subject:
K Nummiaro, E Koller-Meier, L Van Gool, An adaptive color-based particle filter, Image and Vision Computing, 2003 - Elsevier

03 Sep 2009 Hong 4

I found a paper relates to this subject:
K Nummiaro, E Koller-Meier, L Van Gool, An adaptive color-based particle filter, Image and Vision Computing, 2003 - Elsevier

30 Aug 2009 Yong Zhao

thanks for you sharing, I'll study and discuss with all of you.

19 Aug 2009 Janayna

did you use any paper to implement the particle filter?
Thank you

18 Jul 2009 Fang-I Chu

can i ask if i want to track a moving object under grayscale, what is it different from color tracking?

17 Jun 2009 yasong guo

i have solve it now!thank you for your codes .wonderful!thank you!!!

09 Mar 2009 Sebastien PARIS

Ok, you can replace the aviread function with the new one 'mmreader' to read avi files.

08 Mar 2009 M

I get the following error on Windows Vista (64-bit) and MATLAB R2008b. Can anyone assist?

??? Error using ==> aviread at 76
Unable to locate decompressor to decompress video stream

Error in ==> test_pf_colortracker at 196
mov = aviread(video , offset_frame + 1);

PS: I tried installing CINEPAK, but it didnt work! :(

28 Nov 2008 Tedo Biresaw

Wow! what really a nice work.
I get it work.

26 Nov 2008 Sebastien PARIS

Ok, I'll update with a mexmefirt.m file for mexfilers beginners

Thx all for comments/ratings

25 Nov 2008 Ravi Prakash

For all those laymen like me who couldn't get it to work in the first attempt. Type inside the MATLAB command window

> mex ellipse.c
> mex rgb2hsv_mex.c
> mex pdfcolor_ellipserand.c

In both files part_moment.c and particle_resampling.c at the top add the line
#define max(a,b) ( (a) >= (b) ? (a) : (b) )

Then
> mex part_moment.c
> mex particle_resampling.c

Finally to run
> test_pf_colortracker

Thanks Sebastien. FIGHT ON!!

29 Oct 2008 David Norville

Got it to work. Thanks

27 Oct 2008 David Norville

I'm having some trouble recompiling with the part_moment.c file. It says there is an undefinded reference to '_max'. Can you help me please.

21 Oct 2008 XU FENGLIANG

thanks for you sharing

09 Sep 2008 min hu

thanks for program.it is very good.

28 Jun 2008 nauha jam

Thanks for program.I would ask about the LAB model of color image in matlab

05 May 2008 prabhakar raj

i want the code for tracking faces in an image sequence using particle filter,can u help me in this

15 Apr 2008 li jackey

how to recompile mex files?when the file is compiled in VC platform,the problem is always that mex.h can't be found,how to deal with it ,please tell me quickly,thank you

03 Mar 2008 ophelka flowerfairy

to recompile simply use
mex filename.c

02 Mar 2008 Sébastien Paris

Please recompile with the following command :

mex -output rgb2hsv_mex.dll rgb2hsv_mex.c

02 Mar 2008 loi yii tien

Actually i am doing the object tracking in video using neural network. Can you send me an example of it if you can do it. Thanks!

02 Mar 2008 loi yii tien

How to recompile each mex files? and i got error...

??? Invalid MEX-file 'C:\Program Files\MATLAB71\work\pf_colortracker\rgb2hsv_mex.dll': The specified procedure could not be found.

.

Error in ==> test_pf_colortracker at 202
im = rgb2hsv_mex(Z);

hope to hear u soon!

02 Mar 2008 loi yii tien

How to recompile each mex files?

12 Dec 2007 Tom Pinkiewicz

It works now and it looks excellent. Well done!

12 Dec 2007 Sebastien PARIS

You are right. I have just update with the missing file. Thx you....

11 Dec 2007 Tom Pinkiewicz

The C files compiled okay but I get an error that function part_moment is undefined. Are you missing a file with this function?

Updates
27 Jul 2009

-Minor changes

28 Dec 2010

-Add Linux64 with GCC support

13 Nov 2011

-Add likelihood based on gradient distribution
-Use mmreader instead of aviread

05 Jul 2012

-add #define max & min for LCC compiler

Contact us