一、读取NTU-RGB-D数据集
本文基于matlab2016实现。并需要先下载NTU-RGB-D数据集,打开下载的压缩包得到的是一组后缀名为skeleton 的文件,如图1.1所示
图1.1 NTU-RGB-D数据集中的 skeleton文件
主函数如下
clc
clear
skeletonfilename = 'C:\Users\赵迪\Downloads\Raw_Skeleton_S01-S17\skeleton+D0-30000\S001C001P001R001A001.skeleton';
frames_count = 50;%用到的帧数
pic_num = 1;% 输出为gif文件用到的参数
bodyinfo = read_skeleton_file(skeletonfilename);
bodyinfo_frame=bodyinfo(103);
plot_frame(bodyinfo_frame);
figure(1);
for i = 1:numel(bodyinfo)
bodyinfo_frame=bodyinfo(i);
pause(0.05);
plot_frame(bodyinfo_frame);
F=getframe(gcf);
I=frame2im(F);
[I,map]=rgb2ind(I,256);
if pic_num == 1
imwrite(I,map,'S001C001P001R001A001.gif','gif','Loopcount',inf,'DelayTime',0.2);
else
imwrite(I,map,'S001C001P001R001A001.gif','gif','WriteMode','append','DelayTime',0.2);
end
pic_num = pic_num + 1;
end
主函数包含读取skeleton文件,画图,生成gif三个步骤,读取 skeleton文件的函数名为
read_skeleton_file
函数内容为
function bodyinfo = read_skeleton_file(filename)
% Reads an .skeleton file from "NTU RGB+D 3D Action Recognition Dataset".
%
% Argrument:
% filename: full adress and filename of the .skeleton file.
%
% For further information please refer to:
% NTU RGB+D dataset's webpage:
% http://rose1.ntu.edu.