-
Notifications
You must be signed in to change notification settings - Fork 96
/
create_list_kinetics.m
73 lines (44 loc) · 1.79 KB
/
create_list_kinetics.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
% Create list of videos
%Paths
path_save_list='/kinetics/data_list/';
path_DB_rgb='/datasets/kinetics/train/db_frames//';
%Parameters
path_trainList_rgb=fullfile(path_save_list,'kinetics_rgb_train.txt');
fileIDTrain_rgb = fopen(path_trainList_rgb,'w');
action_map_path='class_ind_map_kinetics.mat';
action_map=load(action_map_path);
action_map=action_map.class_ind;
action_list_vid = clean_dir(path_DB_rgb);
for i_activity=1:length(action_list_vid)
i_activity
vid_list_path=fullfile(path_DB_rgb,action_list_vid{i_activity});
video_list_act = clean_dir(vid_list_path);
action_label=find(strcmp({action_map.new_name}, action_list_vid{i_activity})==1)-1;
for i_video=1:length(video_list_act)
display(['activity: ',num2str(i_activity),':',action_list_vid{i_activity},'-video:',video_list_act{i_video}])
path_data_rgb=fullfile(path_DB_rgb,action_list_vid{i_activity},video_list_act{i_video},'/');
len_video=calc_video_len(path_data_rgb);
if (~isempty(len_video))&&(len_video>5)
fprintf(fileIDTrain_rgb,'%s %d %d\r\n',path_data_rgb,len_video,action_label);
end
end
end
fclose(fileIDTrain_rgb);
function files = clean_dir(base)
%clean_dir just runs dir and eliminates files in a folder
files = dir(base);
files_tmp = {};
for i = 1:length(files)
if strncmpi(files(i).name, '.',1) == 0
files_tmp{length(files_tmp)+1} = files(i).name;
end
end
files = files_tmp;
end
function len_video=calc_video_len(video_name)
%calculate the length of videos
framesList_temp = dir([video_name,'/*.jpg']);
framelist_temp={framesList_temp(:).name};
framelist = setdiff(framelist_temp,{'.','..','.DS_Store','.AppleDouble','.compress_folders.sh.swo'});
len_video=length(framelist);
end