diff --git a/recognition/activity_recognition.m b/recognition/activity_recognition.m index aade204..a019253 100644 --- a/recognition/activity_recognition.m +++ b/recognition/activity_recognition.m @@ -6,8 +6,9 @@ lambda = 0.0015; sigma = 1; end - - sequence = 76:125; + + disp('running recognition...') + sequence = 76:125; % remove first 75 unstable points, cannot be larger, or Index exceeds matrix dimensions time_kcc = zeros(13,1); time_dtw = zeros(13,1); @@ -37,7 +38,6 @@ time_kcc(activity_test) = time_kcc(activity_test) + toc; tic -% distance(subject, 5*(activity-1)+ samples, 5*(activity_test-1)+ samples_test) = 0; distance(subject, 5*(activity-1)+ samples, 5*(activity_test-1)+ samples_test) = dtw(train', test'); time_dtw(activity_test) = time_dtw(activity_test) + toc; end @@ -49,9 +49,10 @@ time_use = [time_kcc, time_dtw]; filename = 'results.mat'; save(filename, 'response', 'distance', 'time_use'); - [accuracy_kcc, accuracy_dtw] = show_results(filename); - results = [accuracy_dtw, accuracy_kcc, time_dtw, time_kcc, sigma, lambda]; - fprintf('accuracy_dtw: %f; accuracy_kcc: %f; time_dtw: %f, time_kcc: %f; sigma: %f lambda: %f\n', ... + disp('Saved results to results.mat') + [accuracy_kcc, accuracy_dtw] = show_results(); + results = [accuracy_dtw, accuracy_kcc, sum(time_dtw), sum(time_kcc), sigma, lambda]; + fprintf('accuracy_dtw: %f; accuracy_kcc: %f; time_dtw: %f s, time_kcc: %f s; sigma: %f lambda: %f\n', ... results(1), results(2), results(3), results(4), results(5), results(6)); - + disp('Done.') end diff --git a/recognition/comparison_results.txt b/recognition/comparison_results.txt deleted file mode 100644 index 74e55bf..0000000 --- a/recognition/comparison_results.txt +++ /dev/null @@ -1,17 +0,0 @@ -\begin{tabular}{|l|l|l|l|} -\hline -74&63.5&119.0911&161.0318\\\hline -75.5&66&116.525&156.9842\\\hline -72&72.5&116.66&157.161\\\hline -96&87&116.6862&157.8734\\\hline -93&80&116.7369&157.3694\\\hline -94.5&84&113.9792&153.9453\\\hline -95.5&80&115.4979&155.2064\\\hline -95&83&116.6258&157.0647\\\hline -94.5&80&116.5067&157.0048\\\hline -99.5&79&116.4776&157.2347\\\hline -100&95&116.5865&157.0245\\\hline -97&86&116.4139&157.0018\\\hline -92.5&69&115.3224&155.4016\\\hline -90.6923&78.8462&116.393&156.9464\\\hline -\end{tabular} diff --git a/recognition/data_conversion.m b/recognition/data_conversion.m index 5925a48..f588f15 100644 --- a/recognition/data_conversion.m +++ b/recognition/data_conversion.m @@ -3,6 +3,29 @@ % folder = './WARD1.0/'; addpath('./natsortfiles/') + +if ~(7==exist(folder,'dir')) + url = 'https://people.eecs.berkeley.edu/~yang/software/WAR/WARD1.zip'; + filename = 'WARD1.zip'; + disp('Downloading database...') + websave(filename,url); + disp('Extracting files...') + try + unzip(filename, '.'); + catch err + disp('Unable to upzip, you may need to download/unzip the database to currently folder manually via link:') + disp(url) + return + end + disp('Extracted.') +end + +if (7==exist(folder,'dir')) + disp('Data Conversion...') +else + return +end + files = dir(folder); fileIndex = find([files.isdir]); fileIndex = fileIndex(3:end); @@ -38,4 +61,5 @@ end save('data.mat', 'data'); +disp('Done. Saved to data.mat') clear diff --git a/recognition/run_me.m b/recognition/run_me.m new file mode 100644 index 0000000..df12546 --- /dev/null +++ b/recognition/run_me.m @@ -0,0 +1,6 @@ + +data_conversion; % convert database to compatible format + +activity_recognition; % run recognition demo and show results + +%% you may also run show_example after running data_conversion to visulize the signals. \ No newline at end of file diff --git a/recognition/show_results.m b/recognition/show_results.m index 5785a96..26af7c0 100644 --- a/recognition/show_results.m +++ b/recognition/show_results.m @@ -72,16 +72,17 @@ accuracy_dtw = trace(sum_blocks(fusion_matrix_dtw, 5, 5))/sum(fusion_matrix_dtw(:)); if nargin < 1 - fprintf('accuracy kcc: %f; dtw: %f', accuracy_kcc, accuracy_dtw); + fprintf('accuracy kcc: %f; dtw: %f\n', accuracy_kcc, accuracy_dtw); end table_comparison = ... [diag(sum_blocks(fusion_matrix_kcc, 5, 5)./200)*100,... diag(sum_blocks(fusion_matrix_dtw, 5, 5)./200)*100, results.time_use/65/65*1000*1000]; - table_comparison = [table_comparison; mean(table_comparison)] + table_comparison = [table_comparison; mean(table_comparison)]; matrix2latex(table_comparison, 'comparison_results.txt'); +% disp('Saved results table to Latex codes into comarison_results.txt') function out = sum_blocks(A, block_nrows, block_ncols) out = squeeze(sum(reshape(sum(reshape(A,block_nrows,[])),...