-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchoose_video.m
37 lines (29 loc) · 921 Bytes
/
choose_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
function video_name = choose_video(base_path)
%CHOOSE_VIDEO
% Allows the user to choose a video (sub-folder in the given path).
%
% Joao F. Henriques, 2014
% http://www.isr.uc.pt/~henriques/
%process path to make sure it's uniform
if ispc(), base_path = strrep(base_path, '\', '/'); end
if base_path(end) ~= '/', base_path(end+1) = '/'; end
%list all sub-folders
contents = dir(base_path);
names = {};
for k = 1:numel(contents),
name = contents(k).name;
if isdir([base_path name]) && ~any(strcmp(name, {'.', '..'})),
names{end+1} = name; %#ok
end
end
%no sub-folders found
if isempty(names), video_name = []; return; end
%choice GUI
choice = listdlg('ListString',names, 'Name','Choose video', 'SelectionMode','single');
%choice='Bird1';
if isempty(choice), %user cancelled
video_name = [];
else
video_name = names{choice};
end
end