-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoadVideo.m
More file actions
executable file
·80 lines (55 loc) · 2.69 KB
/
LoadVideo.m
File metadata and controls
executable file
·80 lines (55 loc) · 2.69 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
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
function PAR = LoadVideo
%This function allows the user to select any image in the video sequence
%so that the tracker saves the video path and filename information.
% display('Locate the folder where you would like to save the tracker solution');
% PAR.solutionpath = uigetdir('','Locate the folder where you would like to save the tracker solution');
% %Add a forward slash
% PAR.solutionpath = [PAR.solutionpath '/'];
PAR.solutionpath = ['solutions/'];
% [FileName,PathName] = uigetfile({'*.bmp';'*.tif'},'Click on any image in video sequence',PAR.solutionpath);
FileName = 'exp095000001.bmp';
PathName = '/home/florian/DATA/flighttracker/Takeoff/exp095/cam001/';
temp = imread([PathName FileName],FileName(end-2:end));
PAR.imgres = size(temp);
PAR.imgres_crop = PAR.imgres;
PAR.image_filter = ['*' FileName(end-3:end)];
dir_str = findstr(filesep,PathName);
PAR.imagepath = PathName(1:dir_str(end-1)); % get path one folder up
% I assume that there are subfolders inside PAR.imagepath that begin with
% "cam*"
PAR.imagefilename = FileName;
filenameCells = makeFileList(PathName, PAR.image_filter );
PAR.stub = findRoot( filenameCells );
PAR.numframes = findFrames( filenameCells, PAR.stub );
%Clear the comand window
clc;
%--------------------------------------------------------------------------
function filenameCells = makeFileList( path, image_filter )
% Get list of all .bmp files in directory
namesStruct = dir( [path , image_filter] ); % struct array :)
namesStruct_length = length( namesStruct ); % number of files in each folder
% Sort the list
filenameCells = {namesStruct(:).name};
filenameCells = sort( filenameCells );
%--------------------------------------------------------------------------
function file_root = findRoot( filenameCells )
% Find the root of the file name (without frame values appended) - the only
% assumption made is that the name is of the form [root, numbers].bmp
% Names should be in order, so compare first and last to get value range
% All letters 1:n-1 are the root, n:end are the frame numbers
root = 1;
n = 0;
while root == 1
n = n + 1;
root = strncmp(filenameCells{1}, filenameCells{end}, n);
end
file_root = filenameCells{1}(1:n-1);
%--------------------------------------------------------------------------
function frames = findFrames( filenameCells, file_root );
% HARDWIRED: length of appended file type is 4
ft_length = 4;
n = length(filenameCells{1}) - length(file_root) - ft_length;
% Assume last four string values are the suffix (usually .bmp)
first_frame = str2num(filenameCells{1}(end-(ft_length+n-1):end-ft_length));
last_frame = str2num(filenameCells{end}(end-(ft_length+n-1):end-ft_length));
frames = last_frame - first_frame + 1;