-
Notifications
You must be signed in to change notification settings - Fork 3
/
dronedataflow.m
136 lines (119 loc) · 5.94 KB
/
dronedataflow.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
function dronedataflow
%% Setup
% Add drone dataflow functions to MATLAB path
addpath(genpath('common'))
% Create struct with GUI elements (tabs, descriptions and buttons)
GUIstruct.name = 'Process single flight';
GUIstruct.description = 'Process the images or maps from a single flight.';
buttons.name = 'Detect GCPs';
buttons.func = 'main_detectGCPs.m';
buttons.description = 'Detect, review and export GCPs in images located in folder.';
buttons(2).name = 'Extract ROIs';
buttons(2).func = 'main_extractROIs.m';
buttons(2).description = 'Extract ROIs from georeferenced maps.';
GUIstruct.buttons = buttons;
GUIstruct(2).name = 'Process multiple flights';
GUIstruct(2).description = 'Process the images or maps from multiple flights.';
clear buttons;
buttons.name = 'Detect GCPs';
buttons.func = 'batch_detectGPCs.m';
buttons.description = 'Detect GCPs in images for several folders.';
buttons(2).name = 'Review GCPs';
buttons(2).func = 'batch_reviewROIs.m';
buttons(2).description = 'Review detected GCPs for multiple folders.';
buttons(3).name = 'Extract ROIs';
buttons(3).func = 'batch_extractROIs.m';
buttons(3).description = 'Extract ROIs from maps from multiple flights.';
GUIstruct(2).buttons = buttons;
GUIstruct(3).name = 'Utilities';
GUIstruct(3).description = 'Utility functions';
clear buttons;
buttons.name = 'Crop map to polygon';
buttons.func = fullfile('Utilities','main_cropMap.m');
buttons.description = 'Specify interactively the corners of a polygon and crop the map to the polygon.';
buttons(2).name = 'Show ROIs on map';
buttons(2).func = fullfile('Utilities','main_showROIsOnMap.m');
buttons(2).description = 'Load and plot ROIs on a user specified map.';
GUIstruct(3).buttons = buttons;
GUIstruct(4).name = 'Advanced';
GUIstruct(4).description = 'Setup utilities';
clear buttons;
buttons.name = 'Create new camera model';
buttons.func = fullfile('common','cameras','main_saveCameraModel.m');
buttons.description = 'Specify parameters for a new camera model. Both perspective and fisheye models are supported.';
GUIstruct(4).buttons = buttons;
%% Construct the components
% Initial struct for handles
handles = struct;
handles.fig = figure('Visible','off','Position',[1 1 450 300],'Resize','off');
% Remove built-in menu bar
set(gcf,'MenuBar','none')
% Remove figure number from title and set title of figure
set(gcf, 'NumberTitle', 'off', 'Name', 'Drone Dataflow');
% Create tabs
handles.tgroup = uitabgroup('Parent', handles.fig,'TabLocation', 'left');
for t = 1:length(GUIstruct)
tabStruct = GUIstruct(t);
handles.tab(t) = uitab('Parent', handles.tgroup, 'Title', tabStruct.name,'Units','Pixels');
buttons = tabStruct.buttons;
tabHandles = struct;
for b = 1:length(buttons)
action = buttons(b);
% Create panel
inner_position = get(handles.tab(t),'InnerPosition');
handles.pan(b) = uipanel('Parent', handles.tab(t), ...
'Title', action.name, ...
'FontWeight','bold', ...
'Units', 'Pixels', ...
'Position', [10 inner_position(4)-(b*90) 300 80]); % inner_position(3)-(10+(b-1)*90)
% Create description text
tabHandles.text(b) = uicontrol('Parent', handles.pan(b), ...
'Style', 'Text', ...
'String', action.description, ...
'HorizontalAlignment', 'Left', ...
'Position', [5 5 200 60]);
% Create "Run script" button
tabHandles.btnRun(b) = uicontrol('Parent', handles.pan(b), ...
'Style', 'PushButton', ...
'String', 'Run script', ...
'HorizontalAlignment', 'Center', ...
'Position', [215 5 80 20], ...
'Callback', {@callback_run, action});
% Create "View code" button
tabHandles.btnView(b) = uicontrol('Parent', handles.pan(b), ...
'Style', 'PushButton', ...
'String', 'View code', ...
'HorizontalAlignment', 'Center', ...
'Position', [215 30 80 20], ...
'Callback', {@callback_view, action});
end
end
%% Initialization tasks
% Set figure position to center of screen
screen_size = get( groot, 'Screensize' );
figure_position = get(handles.fig,'Position');
figure_offset_left = (screen_size(3)-figure_position(3))/2;
figure_offset_bottom = (screen_size(4)-figure_position(4))/2;
set(handles.fig, 'Position',[figure_offset_left figure_offset_bottom figure_position(3:4)])
% Show figure/GUI
set(handles.fig,'Visible','on');
%% Set callbacks
end
function callback_run(hObject, callbackdata, button)
disp('---------------------------')
disp(['Action : Run script'])
disp(['Name : ' button.name])
disp(['Script : ' button.func])
disp(['Description: ' button.description])
disp('---------------------------')
run(button.func)
end
function callback_view(hObject, callbackdata, button)
disp('---------------------------')
disp(['Action : View code'])
disp(['Name : ' button.name])
disp(['Script : ' button.func])
disp(['Description: ' button.description])
disp('---------------------------')
open(button.func)
end