forked from Mrahman17/mmWave-Radar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcut_Video.m
59 lines (37 loc) · 1.72 KB
/
cut_Video.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
clc; clear; close all;
main = '/mnt/HDD01/rspl-admin/DATASETS/110 Words ASL Fall 2020/Output/';
subjects = dir(main);
subjects = subjects(3:end);
for s = 1:length(subjects)
labelpath = [main subjects(s).name '/rangeDoppler/labels/*.txt'];
labels = dir(labelpath);
vidpath = [main subjects(s).name '/rangeDOA/*.avi'];
vids = dir(vidpath);
cutpath = [main subjects(s).name '/rangeDOA/Cut/'];
if s ==4
z = 1;
else
z = 1;
end
for i = z:length(labels)
fname = labels(i).name(1:end-4);
match = strfind({vids.name},fname);
idx = find(~cellfun(@isempty,match)); % find non-empty indices
fIn = fullfile(vids(idx).folder,vids(idx).name);
y = load(fullfile(labels(i).folder,labels(i).name));
mask = logical(y); %(:).' to force row vector
starts = strfind([false, mask], [0 1]);
stops = strfind([mask, false], [1 0]);
if length(starts) ~= length(stops)
stops = [stops 570];
end
for j = 1:length(starts)
msg = ['Processing: Subject ' int2str(s) ', File: ' int2str(i) ' of ' int2str(length(labels)) ', Part ' ...
num2str(j) '/' num2str(length(starts))]; % loading message
disp(msg);
label = mode(y(starts(j):stops(j)));
fOut = [cutpath fname '_' num2str(j) '_' num2str(label)];
cutVideo_label(fIn, fOut, starts(j), stops(j))
end
end
end