A Matlab code is written to recognize human actions namely 'walking', 'jogging','running', 'boxing','hand waving', and 'hand clapping' using Spatio Temporal Interest Points (STIP) and classify the same using a KNN classifier. Please download the KTH Action recognition dataset from the link http://www.nada.kth.se/cvap/actions/ and put them in the folder KTH Dataset folder.
How to run ??
1. Place the 'Action Recognition Code' folder in the Matlab Path, add all the folder and subfolder to the path
2. Run Recognize.m
3. Select a video from the KTH Dataset
4. Observe results
The code is loosely based on the paper below, please cite and give credit to the authors:
[1] Schüldt, Christian, Ivan Laptev, and Barbara Caputo. "Recognizing human actions: a local SVM approach." Pattern Recognition, 2004. ICPR 2004. Proceedings of the 17th International Conference on. Vol. 3. IEEE, 2004. ftp://ftp.nada.kth.se/CVAP/users/laptev/icpr04actions.pdf
Suggestions and comments are always welcome
Thanks in advance,
Manu B.N
Manu BN (2019). Human Action Recognition using KTH Dataset (https://www.mathworks.com/matlabcentral/fileexchange/55111-human-action-recognition-using-kth-dataset), MATLAB Central File Exchange. Retrieved .
1.0.0.0 | Cycling and Surfing videos are added |
|
1.0.0.0 | Links are added for reference |
|
1.0.0.0 | Empty forlders Frames and KTH Dataset are added. If you need surfing and cycling videos send an e mail to manubn88@gmail.com |
|
1.0.0.0 | Zip files are added as many found zipx files incompatible |
Create scripts with code, output, and formatted text in a single executable document.
Nisar Bahoo (view profile)
Sir you gone the great work. it is really help full for me as i am looking to do my Final Year Project in this topic. your code helped me alot but sir i am facing a error
Undefined function or variable 'TrainFeat'.
Error in main1>Recognizedaction_Callback (line 120)
X=TrainFeat;
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in main1 (line 43)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)main1('Recognizedaction_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
sir can you plz help me about it, i shall be very thankful to you.
Bashid (view profile)
Bashid (view profile)
https://github.com/ManuBN786/Human-Action-Recognition
Abhishek Yadav (view profile)
Sir I have tried to run the recognise.m file but I'm getting error like
implay([pathname,filename]);
Khac Dat Nguyen (view profile)
Hello,sir.Can you send me tranning project. Thankyou verry much( Email:khacdatnguyen9x@gmail.com)
xuyuan (view profile)
Thanks very much,sir.But it seems some problems.The one when I run main.m and I got this error: Unable to read file 'Trainfeature'. No such file or directory. Another one is that the code can only classify cycling and surfing.I am very confused.
YANG LEI (view profile)
hello,sir.Could you send me the training .m files? Thank you (My email: 15733513567@163.com)
Santhosh Bijinemula (view profile)
Rohit Sangma (view profile)
Sir can you please send me training data? Email: rohitssnal@gmail.com
Banafshe Felfeliyan (view profile)
Asanka Perera (view profile)
Asanka Perera (view profile)
susanta reang (view profile)
what is the exact command for confusionmat?
susanta reang (view profile)
Undefined function or variable 'TrainFeature'.
Error in main1>Recognizedaction_Callback (line 80)
X=TrainFeature;
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in main1 (line 20)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)main1('Recognizedaction_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
i am getting this error . how do i resolve it?
ammar sirine (view profile)
Can you please send me the code? My email is: ammarsirine3@gmail.com
Rakshith Hegde (view profile)
Hello sir, I want to recognize unusual activities like falling, crawling & suffering. How it can be done?
Junaid Ibrahim (view profile)
Can you please send training.m and test.m files? Email id junaidibrahim90@gmail.com
Foram Suratwala (view profile)
Can you please send training data.mat file ? Email id foram89833@gmail.com
Foram Suratwala (view profile)
Can you please send me the code?Email: foram89833@gmail.com
Tanmoy Ghosh (view profile)
Priya HE (view profile)
sir, how many frames are divided for 1 second in your code.
Is there any constraint to upload a new video which is not trained.
please mail the solution at priyahe66@gmail.com
Shruthi H K (view profile)
sir can you please tell me how to recognize the action from the new video which is not included in the trained dataset????
sir please send me the solution to this mail hkshruthi15@gmail.com
Bhushan Deo (view profile)
anuradha Kulkarni (view profile)
could you please send me algorithm at : anu.kulkarni1919@gmail.com
River Wang (view profile)
Could u please sent me the training.m file to my email. (1208211893@qq.com)
Prashant Patel (view profile)
Prashant Patel (view profile)
Plz sent algorithm my emailid :prashantpatel22222@gmail.com
Suma Kamireddy (view profile)
Thanks for the code.I have a doubt that where did you use the temporal Information in the code for extracting the STIP points
Reem Alfaifi (view profile)
thanks, I want to ask you what is meaning of matrix meas in TrainFeat.mat
can you please help me?
Reem Alfaifi (view profile)
thanks, I want to ask you what is meaning of matrix X in TrainFeat.mat
can you please help me?
shubhamraj singh (view profile)
Akash Hegde (view profile)
Mashazrina Hadri (view profile)
when I run the recognize.m, I got this error. Can you help me to solve it? thanks
Error using imwrite (line 467)
Unable to open file "Frames\11.jpg" for writing. You might not
have write permission.
Error in Recognize (line 24)
imwrite(mov(k).cdata,['Frames\1',num2str(k),'.jpg']);
Moussa BA (view profile)
I run main.m and I got this error: Unable to read file 'Trainfeature'. No such file or directory.
Can you give the file train.m please, my email is: emb5828@umoncton.ca, thx you!
DEEPAK PHCSFI17041149 (view profile)
It works, you have to check the Type variable for the classification results @Jane Hui
Jane Hui (view profile)
I have run the "Recognize.m". It can successfuly recognize cycling and surfing. However, If I choose another video, it does't work. Did someone else meet the same problem? Or, somebody kind can help me.
DEEPAK PHCSFI17041149 (view profile)
DEEPAK PHCSFI17041149 (view profile)
Guys That was a very beautiful piece of code from @Manu BN
Great work Manu.
I am just trying to give my understanding over the code to clear the confusion here, a bit.
The Code can run any on any test video from KTH(Single human action recognition) dataset.
In Recognize.m File You can see the Type = predict(md1,Z); so obviously TYPE is the variable you have to look for obtaining the confusion matrix among the 8 class. and unfortunately when i run the code "Running" is the only action which has been recognized with an accuracy of 50%. All the other actions are mostly miss-classified as Surfing.
And i hope this is because of extracting the features on frame level since i can see the test variable is an 50x1 dimension varaible, which is to my understanding that only 50 frames are considered for classification during the training.but this code worked as a little dynamite to my study over action recognition.
The code works on all the videos in the KTH dataset, the final pop-up doesnot appear since the classifiaction results are so sparse. But still you can get the recognition accuracy of the test video in the Type(50*1) variable. which in turn shows how many frames are classified correctly from 50 input frames.
In Case if u need more accuracy over actions you train the classifier with more input data/ Clip level data with a little change of the code provided here.
Thanks Manu,
It would be very helpful if u perform clip based classification with different appearance and motion features like MBH/HOF, it would be a noble contribution.
Great work Bro!!!
Jane Hui (view profile)
Thank you for your code! I' ve just run. It worked. But it seems that the code can only classify cycling and surfing. I was wondering if the .avi name has special meaning. It prints out "surfing"because the video name is 8? That makes me confused. Perhaps I should have a deep think. All in all, thanks.
Swdwmsri Baglary (view profile)
can you please send me the code?(email: swdwmsribaglary14@gmail.com)
harsh srivastava (view profile)
please send me train.m file to harshs613@gmail.com
sathiya (view profile)
kindly send me the code to sathiysavi@gmail.com
Thanks in advance
Lucy (view profile)
Could you send me the training .m files? Thank you (My email: 1215110906@qq.com)
Mce (view profile)
hasan molla (view profile)
what is the function of maxsupression.m
harsh srivastava (view profile)
can you send me train.m file ..pls my email is harshs613@gmail.com
Zeeshan Ahmad (view profile)
while running the code following error occurs.
"Undefined function or method 'VideoReader' for input arguments of type 'char'."
can you help me in this regards
Thanks in advance
Volkan Ulutas (view profile)
Great work! Can you send me the training.m files? Thanks in advance (my e-mail: volkanulutas@gmail.com)
kerlos nasser (view profile)
Can you send me the training,m file, please?
My email: Famirous.Fam@gmail.com
Thanks in advance
@Faisal imtiaz This is my email I would like you to end me a training.m file, please?
Thanks in advance
Gözde Nergiz (view profile)
Could you send me the training .m files? Thank you (My email:gzdenrgz001@gmail.com)
Wishakha (view profile)
I want to extend this project for some other activities.Can you please explain how the training can be performed?
Manu BN (view profile)
@ Santosh: Plz go thro all the comments & description. I have placed links to description
@ Mohanad: STIP is the feature set
Thanks to all for the rating
Santhosh Bijinemula (view profile)
can u provide me the resources,which are useful to understand the code !
email-id : santhoshbijinemula@gmail.com
Thank you ! :) !!
Santhosh Bijinemula (view profile)
Wishakha (view profile)
mohanad babiker (view profile)
which features did you used for classification ,in general bounding box area and centroid is it enough to distinguish between each activity in kth video ??
huang junjian (view profile)
Could you send me the training .m files? Thank you (My email: 402986395@qq.com)
Student university (view profile)
Fatttouma (view profile)
AMIT (view profile)
hello Manu,
this code is really a great help for me in my work.
I just want to know how you create the trainfeat matrix and also what feature you use for it.
Thanks and Regards
Manu BN (view profile)
@ Wei Jie: You are correct about everytinh man. Thanks for the rating
Mohammed Azfar Usman (view profile)
Can you send me the train.m file? My email : 13bscsmusman@gmail.com
Todd Mobley (view profile)
I'm on a mac and experiencing the same issue as one person below. If I run "Recognize" on videos 7 and 8 (already in the KTH dataset folder), it outputs the correct action. If I run the code on any of the 6 ((DivX-compressed) videos, it outputs the frames, but no action (running, jogging, etc)
Wei-Jie Chen (view profile)
Wei-Jie Chen (view profile)
Thanks for sharing code. That helpful for my work! Some Questions as following:
1.About the feature abstraction function STIP. Can you detail or explain the meaning about parameters and returns.[posinit,valinit]=STIP(f1,kparam,sxl2,sxi2,pointtype,nptsmax);
2. About the training dataset constructing: I choose a "video clips" for sample, then use "STIP" function to abstract the features (40 dimensions/valinit), and assign a label to this sample. Is that's OK for my understanding?
3. The sample is "video clips" (has 50 frames) not just "a frame picture"?
4. As for 'TrainFeat.mat', it has 50 samples per class?
In a word, that's a fantastic work for me!!! Thanks again!
Wei-Jie Chen (view profile)
Lee Seah (view profile)
And bro for the code u provided i able to follow these few step( select a video-> frame conversion-> preprocessing ->corner detection->pruning) but when i click for show me the result it show error. May i know what error is that?
Lee Seah (view profile)
Could you send me the training .m files? Thank you (my email: leeyuseah@gmail.com
Manu BN (view profile)
@ Faisal: It works perfectly. You have to wait until the pop up window appears
@xuxiansheng, Huy: Train.m can be created by reading all the frames from a video file and storing the features in a .mat file and next give a label 1,2 etc based on the classes and save it. Use the same method of feature extraction that I have done here.
@ Leek: Only 6 videos from the link mentioned. For others train it yourself.
For detailed explanation of feature set go thro youtube links mentioned in one of the below comments
Thanks to all for the ratings
Huy Pham (view profile)
Could you send me the training .m files? Thank you (My email: huyulsan@gmail.com)
leek Luo (view profile)
I can't figure out the use of harrislpls.m. Could you please explain a little?Also, after reading all the comments, I'm still wondering if you use the whole KTH dataset to train your classifier or only used 6 sample video to train your classifier?I can recognize 2 upload clips 7.avi,8.avi and 6 sample avi you mentioned and others would fail.Did I mess up something?Thanks.
xuxiansheng (view profile)
@Faisal imtiaz My email is peizenxu1@163.com.wo can Communication with it.
Faisal imtiaz (view profile)
@xuxiansheng i can share you the .m for training set,testing with using a single frame in a video and taking whole video as a single entity ,result... improvement in detection of result and improvement with classifier
xuxiansheng (view profile)
i have read the all comments,but i still don't know how to train the other dataset.why not have the train.m.
Faisal imtiaz (view profile)
The end result have decision playing but i am unable to find ,predict type that marked as playing
Faisal imtiaz (view profile)
Sorry for multiple comments and multiple ratting,please all remove repeated comments
Faisal imtiaz (view profile)
code is good,for training,Is valinit from test saveda and 400 training set are created?How can new type be added for predict?
Faisal imtiaz (view profile)
code is good,for training,Is valinit from test saveda and 400 training set are created?How can new type be added for predict?
Faisal imtiaz (view profile)
code is good,for training,Is valinit from test saveda and 400 training set are created?How can new type be added for predict?
Faisal imtiaz (view profile)
Faisal imtiaz (view profile)
Faisal imtiaz (view profile)
Faisal imtiaz (view profile)
FAS (view profile)
Manu BN (view profile)
I suggest u go thro all the comments below as the same question was asked by many ppl
xuxiansheng (view profile)
Thanks for your reply.Only the six sample sequences can be recogniticed.why the others can not be ? I want to train other database,how can i do it
Tasneem Ahmed (view profile)
Thank you for your code. I run the code and I got this error "Undefined function or variable 'meas'. Error in Recognize (line 54)X = meas ,if you don't mind plz help me to solve this problem
Manu BN (view profile)
@xuxiansheng: Type value will be based on the label assigned to the videos. Are u downloading the KTH with 6 videos and not the others ones available in same website.
FAS (view profile)
xuxiansheng (view profile)
i have run the code again.When I set a breakpoint,i find the "Type"value is not consistent.so it has not output.When i choose to output the most of the value.NO matter i choose the walking,jogging or boxing it will output surfing.only when i choose the running it can recognitice.Can you tell me why?Thank you!
Manu BN (view profile)
plz go thro all the comments below
xuxiansheng (view profile)
Thank you for your code.but i have some questinos.when i chose the "7.avi or 8.avi",it can recognition .when i chose the KTH dataset it can not output the stytle.can you tell me why? thank you
xandratom (view profile)
Curiosity: In the STIP function, where are temporal directions taken into account?
Manu BN (view profile)
I have trained it using KTH. If you want you can try Weizman Caltech etc. Use the same procedure for feature extraction.
xandratom (view profile)
Is it possible to have more information about the training dataset? Or has the classifier been trained on the KTH dataset itself?
Manu BN (view profile)
Go thro all the comments below.... you will understand
xandratom (view profile)
Ok, actually problem solved. It was a format problem, caused the Video Reader function on Macintosh. As soon as I moved to Windows, no problem. At least on the datasets suggested by you, but the code doesn't seem to work on videos that I manipulate.
xandratom (view profile)
I have the same problems that other have: the code apparently is not working with the downloaded videos. I don't understand why, since the format and the dimensions are correct. I am pretty sure I am doing nothing wrong, actually.
Manu BN (view profile)
Its the exact implementation !!!
Aliyu (view profile)
Thanks Mr Manu for sharing you code. I am wandering how I can extract the HOG and HOF directly using your code as implemented by Laptev?
Manu BN (view profile)
If you can go through Dr. Laptev's paper and maybe watch his video
https://www.youtube.com/watch?v=mbd_k7XARmg.
Its more than sufficient to understand HAR
Rajesh Shekokar (view profile)
dear all, where can i get literature abt. the code. I want flowchart of processing and complete information reg. all functions used in the code in relation with the flowchart.
Manu BN (view profile)
@Dongxu: method for extracting the features for training is same as the one given here for testing. You just have to assign a label and save it using 'save' command.
thanks to all for the ratings.
Dongxu Gao (view profile)
Do you also provide the code for getting the "TrainFeat.mat"?
rachna kasnia (view profile)
Venkat R (view profile)
Very useful submission
Tyou (view profile)
Manu BN (view profile)
Use one vs all approach for evaluating accuracy. The Matlab command 'confusionmat()' will plot it. main.m is not the file, Recognize.m is.
mennatullah abdelawad (view profile)
how you are testing for accuracy and calculating confusion matrix ? and how i can use your gui when i opened main.fig and load the video it gave me errors ? thank you
hiep ga (view profile)
you can lead a more detailed way is not? thank you very much
Manu BN (view profile)
Train it and assign the label and save using 'save' command in Matlab. Follow the same procedure for feature extraction as in the recognize.m
jia lu (view profile)
how can i add new video to this?? and the new video should also 256*256 right??
hiep ga (view profile)
If I download the data in zip files then I I have to do to recognition. plz help me. thanks
Manu BN (view profile)
Pretty soon I will come up with a documentation and a tutorial for training. I just checked , it works perfectly for hand clapping.
menna mustafa (view profile)
could you please add a documentation for the code and the parameters of the function? , and the classifier works fine for all the KTH dataset except handclapping
Manu BN (view profile)
The paper gives a very detailed description of spatio temporal interest points, plz go thro it first. If you want further details watch video by Dr. Laptev himself: https://www.youtube.com/watch?v=mbd_k7XARmg.
Videos lectures by Dr. Mubarak Shah also give an awesome explanation.
Regarding training a classifier: first workout basic examples using Fisher Iris etc. and go thro this code, you will get ideas to train on your own. Plenty of online tutorials are also available.
Aniruddha Tapas (view profile)
Thank you so much for the code.
It works perfectly on Matlab 2013a with correct predicion. However it is kind of a blackbox for us..
How did you train the classifier? Can you please explain the working procedure behind it and the use of the main files in the project?
It would be really helpful for me..
Thanks again!
Manu BN (view profile)
I will make a video of how to run and paste the link here ASAP. Plz wait for few more days. The code is working correctly on KTH.
Manu BN (view profile)
You need to download tha Divx files , not the ones in zip.
Come on.... this is the 5th time i'm checking but the code is working perfectly in Matlab 2013. The pop up and the command window results are appearing perfectly.
Arsalan khan (view profile)
Dear Manu,
Neffati is right, its working on your given videos in uploaded file. its not working on KTH dataset.
Syrine Neffati (view profile)
I’m sure that the code is working, I’m just not getting what I am doing wrong here
Manu BN (view profile)
Download the 6 videos from the link and put it in the folder. The code has more than 100 downloads/month i'm quite sure you are making some mistake. Once its broken to frames, in few seconds a pop up dialogue box will tell the type.
Syrine Neffati (view profile)
Thank you sir for updating the code.
When I apply the code on the two videos found with the updated version (cycling / surfing) it works perfectly, but when I try to apply it on one of the videos of the KTH dataset it does not work: 50 frames appear and that’s it.
The pop up dialogue don’t appear and I do not see any prediction.
I would be thankful if you can help me fix the problem
Manu BN (view profile)
You need to wait for a few seconds for the pop up dialogue box to appear. i have updated the code.
Syrine Neffati (view profile)
I have created a folder named 'Frames’ and the code works perfectly I just don’t see any prediction
Manu BN (view profile)
Please create an empty folder named 'Frames' in the path of the code and then run. I just checked the code again, once the folder is created it works perfectly.
Syrine Neffati (view profile)
Thank you for sharing this code.
Sorry for the inconvenience but I do not see any prediction of the listed activity, after I select a video from KTH dataset, selected video appears and then 50 frames from that video displayed! I feel like I’m missing something.
No pop up dialogue box showing results, no results appears on command window either.
I would be very thankful if you can help me fix this problem
poineer (view profile)
For the variable 'Type',it is a vector,which means the 'Type' should be same in 50 frames,the result can be shown correctly.The condition of judgement is a little harsh ?
Manu BN (view profile)
sure be little more specific
poineer (view profile)
Thank a lot,I am a graduate student doing academic research about human behavior recognition now. Can you give me some suggestions for this subject?
Arsalan khan (view profile)
if you are facing imwrite (file write permission error) then create a folder "Frames" in your folder where "recognize.m" is placed. then run.. I was facing same error but resolved after creation on "Frames" folder.
Sharath K Rangan (view profile)
Hey, i have enabled write permission. It still gives the imwrite error.
Manu BN (view profile)
imwrite error happens when you dont have write permission. right click on the Matlab installed folder go to properties and enable it to write
Sweta Agarwal (view profile)
Sweta Agarwal (view profile)
getting an error using imwrite
sawsen ghabri (view profile)
sorry to bother you but I was not able to fully extract .zipx file. Could you send me the file at sawsen.ghabri.s@ieee.org
Syed Mozammel Hossain (view profile)
Hi, sorry for the inconvenience. I tried but could not solve the problem. It would be appreciated if you send me your code that you are working on. Thanks
Manu BN (view profile)
I'm quite sure you are making some mistake. I just checked the code again, it's working perfectly. In fact this is the only working code in Human Action in whole of Matlab Central.
Thanks for the rating.
Syed Mozammel Hossain (view profile)
Thanks! I figured it out after asking :) But I have observed that most of the time it predict surfing as an activity whatever the selected video is!!! Did I miss something? It would be appreciated if you explain how to solve that. We can communicate through email (hossain31@yahoo.com) if you want. Thanks in advance.
Manu BN (view profile)
A pop up dialogue box shows the results, the same can be seen on command window also.
Syed Mozammel Hossain (view profile)
I am new in Matlab. I tried to run this code and it works perfectly but problem is that I do not see any prediction of the listed activity! As instructed, I select a .avi file from KTH dataset, selected video appears and then 50 frames from that video displayed! Is that all? Sorry for my lack of knowledge if I miss something.
Safak KAYRAN (view profile)
Thx a lot .
Yashaswini MU (view profile)
Done Sir, Thanks a lot for your time and help!
Manu BN (view profile)
I just checked the code, it is working perfectly.
imwrite error happens when you dont have write permission. right click on the Matlab installed folder go to properties and enable it to write.
Yashaswini MU (view profile)
I am using Matlab 2015 version. I tried doing it before. I still doesn't work.
Manu BN (view profile)
First put all the videos in folder 'KTH Dataset', then right click on this folder and select option' add all folders and subfolders'. Then run in Matlab 2013 or higher versions.
Plz rate if possible.
Yashaswini MU (view profile)
Sir, I tried running your code. It gives an error saying
Error using imwrite (line 454)
Unable to open file "Frames\1.jpg" for writing. You might
not have write permission.
How do I solve this error?
Manu BN (view profile)
use the latest version of Winzip.
Sorabh Tomar (view profile)
Hey sorry to bother you but I was not able to fully extract .zipx file. Could you send me the file at sorabhtomar@hotmail.com
Manu BN (view profile)
Thanks for the rating. Plz check out my other projects also.
Sorabh Tomar (view profile)
Man you're a genius! Your code is very nice and elegant. Thanks.