-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprepare_gt_office.m
More file actions
37 lines (35 loc) · 1.05 KB
/
prepare_gt_office.m
File metadata and controls
37 lines (35 loc) · 1.05 KB
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
%Read textfile
%Girmaw A,
%August 13/2015
videoPath='./gt_office_eaf_label/';
addpath(videoPath)
videos= dir(strcat(videoPath,'*.txt'));
videos={videos.name};
numVideos=length(videos)
for sub=1:numVideos
fullfilename=videos{sub};
filename=strtok(fullfilename,'.');
% - Get structure from first line.
fid = fopen( fullfilename, 'r' ) ;
line = fgetl( fid ) ;
fclose( fid ) ;
isStrCol = isnan( str2double( regexp( line, '[^\t]+', 'match' ))) ;
% - Build formatSpec for TEXTSCAN.
fmt = cell( 1, numel(isStrCol) ) ;
fmt(isStrCol) = {'%s'} ;
fmt(~isStrCol) = {'%f'} ;
fmt = [fmt{:}] ;
% - Read full file.
fid = fopen( fullfilename, 'r' ) ;
data = textscan( fid, fmt, Inf, 'Delimiter', '\t' ) ;
fclose( fid ) ;
% - Optional: aggregate columns into large cell array.
for colId = find( ~isStrCol )
data{colId} = num2cell( data{colId} ) ;
end
%data = [data{:}] ;
gt_office.(filename).start_time=cell2mat(data{:,1});
gt_office.(filename).final_time=cell2mat(data{:,3});
gt_office.(filename).label=[data{:,6}];
end%sub
save('gt_office.mat','gt_office');