-
Notifications
You must be signed in to change notification settings - Fork 18
/
multimodal_data_studio.m
201 lines (167 loc) · 9.74 KB
/
multimodal_data_studio.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
function multimodal_data_studio()
% multimodal_data_studio supporting the following functions:
% 1: multi_rosbag tool for image and lidar points operation
% 2: camera_lidar_calibration_toolbox based on correspoding planes matching using chessboard
gui = struct();
% Open a window and add some menus
gui.handle = figure( ...
'Name', 'multimodal_data_studio', ...
'NumberTitle', 'off', ...
'MenuBar', 'none', ...
'Toolbar', 'none', ...
'HandleVisibility', 'on', ...
'Visible', 'on', ...
'Resize', 'off');
figureWidth = 640;
figureHeight = 480;
BoxWidth = 0.2;
BoxHeight = BoxWidth * figureWidth / figureHeight;
BoxLeftMargin = 0.2;
BoxHMargin = 0.2;
BoxVMargin = 0.2;
BoxVPos = 0.6;
set(gui.handle, 'Position', [0 0 figureWidth figureHeight]);
movegui(gui.handle, 'center');
bgColor = [0.94 0.94 0.94];
% set the path
current_file_path = fileparts(which('multimodal_data_studio.m'));
addpath(fullfile(current_file_path, './utils/interface'));
multi_rosbag_image_filename = fullfile(current_file_path, './icons/multi_rosbag.png');
chessboard_camera_lidar_calibration_image_filename = fullfile(current_file_path, './icons/chessboard_camera_lidar_calibration.png');
chessboard_camera_calibration_image_filename = fullfile(current_file_path, './icons/chessboard_camera_calibration.png');
% create the pushbutton play control for multi_rosbag
gui.mPushbuttonMultiRosbagLocation = [BoxLeftMargin + 0*(BoxHMargin + BoxWidth) BoxVPos BoxWidth BoxHeight];
gui.mPushbuttonMultiRosbag = uicontrol('Parent', gui.handle, 'style', 'pushbutton', 'Units', 'normalized', 'Position', gui.mPushbuttonMultiRosbagLocation);
% jh = findjobj(gui.mPushbuttonMultiRosbag);
% jh.setFlyOverAppearance(true); % set the button boarder invisible
set(gui.mPushbuttonMultiRosbag, 'callback', @onButtonMultiRosbag);
% draw the multi_rosbag button image
image = imread(multi_rosbag_image_filename, 'BackGroundColor', bgColor);
gui.mPushbuttonMultiRosbag.Units='pixels';
image = imresize(image, fliplr(gui.mPushbuttonMultiRosbag.Position(1,3:4))); % resize the png to 0.8 of the button boarder
gui.mPushbuttonMultiRosbag.Units='normalized';
gui.mPushbuttonMultiRosbag.CData=image;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% create the pushbutton for camera extrinsic calibration
gui.mPushbuttonChessboardCameraLidarCalibrationLocation = [BoxLeftMargin + 1*(BoxHMargin + BoxWidth) BoxVPos BoxWidth BoxHeight];
gui.mPushbuttonChessboardCameraLidarCalibration = uicontrol('Parent', gui.handle, 'style', 'pushbutton', 'Units', 'normalized', 'Position', gui.mPushbuttonChessboardCameraLidarCalibrationLocation);
% jh = findjobj(gui.mPushbuttonChessboardCameraLidarCalibration);
% jh.setFlyOverAppearance(true); % set the button boarder invisible
set(gui.mPushbuttonChessboardCameraLidarCalibration, 'callback', @onButtonChessboardCameraLidarCalibration);
% draw the cameara-lidar calibration button image
image = imread(chessboard_camera_lidar_calibration_image_filename, 'BackGroundColor', bgColor);
gui.mPushbuttonChessboardCameraLidarCalibration.Units = 'pixels';
image = imresize(image, fliplr(gui.mPushbuttonChessboardCameraLidarCalibration.Position(1,3:4))); % resize the png to 0.8 of the button boarder
gui.mPushbuttonChessboardCameraLidarCalibration.Units = 'normalized';
gui.mPushbuttonChessboardCameraLidarCalibration.CData = image;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% create the pushbutton for camera intrinsic calibration
gui.mPushbuttonChessboardCameraCalibrationLocation = [BoxLeftMargin + 0*(BoxHMargin + BoxWidth) BoxVPos - 1*(BoxHeight + BoxVMargin) BoxWidth BoxHeight];
gui.mPushbuttonChessboardCameraCalibration = uicontrol('Parent', gui.handle, 'style', 'pushbutton', 'Units', 'normalized', 'Position', gui.mPushbuttonChessboardCameraCalibrationLocation);
% jh = findjobj(gui.mPushbuttonChessboardCameraLidarCalibration);
% jh.setFlyOverAppearance(true); % set the button boarder invisible
set(gui.mPushbuttonChessboardCameraCalibration, 'callback', @onButtonChessboardCameraCalibration);
% draw the camera-calibration button image
image = imread(chessboard_camera_calibration_image_filename, 'BackGroundColor', bgColor);
gui.mPushbuttonChessboardCameraCalibration.Units = 'pixels';
image = imresize(image, fliplr(gui.mPushbuttonChessboardCameraCalibration.Position(1,3:4))); % resize the png to 0.8 of the button boarder
gui.mPushbuttonChessboardCameraCalibration.Units = 'normalized';
gui.mPushbuttonChessboardCameraCalibration.CData = image;
function onButtonMultiRosbag(src, event)
ros_data_multiBag_image_point();
end % onButtonMultiRosbag
function onButtonChessboardCameraLidarCalibration(src, event)
configDiag(current_file_path);
end % onButtonChessboardCameraLidarCalibration
function onButtonChessboardCameraCalibration(src, event)
chessboard_camera_calibration(current_file_path);
end % onButtonChessboardCameraCalibration
function configDiag(current_file_path)
data_root = current_file_path;
config_file = 'camera_lidar_calibration_config.yml';
% create a dialog that get the images-points pairs
d = dialog('Position',[700 400 600 150],'Name','Get Data root directory and config file');
% add controls to load the images
txtDataRootFolder = uicontrol('Parent',d, ...
'Style','text', ...
'Units', 'normalized', ...
'Position',[0.0 0.85 - 0.05 0.6 0.2], ...
'HorizontalAlignment', 'left', ...
'String','Data Root Folder:');
editBoxDataRootFolder = uicontrol('Parent', d, ...
'style', 'edit', ...
'Units', 'normalized', ...
'Position', [0.0 0.65 0.8 0.2], ...
'HorizontalAlignment', 'left', ...
'String', current_file_path);
buttonBrowserDataRootFolder = uicontrol('Parent', d, ...
'style', 'pushbutton', ...
'Units', 'normalized', ...
'Position', [0.8 0.65 0.2 0.2], ...
'String', 'browser', ...
'callback', @onBrowserDataRootFolder);
% add control to load the points
txtConfigFile = uicontrol('Parent',d, ...
'Style','text', ...
'Units', 'normalized', ...
'Position',[0.0 0.45 - 0.05 0.6 0.2], ...
'HorizontalAlignment', 'left', ...
'String','Config File:');
editBoxConfigFile = uicontrol('Parent', d, ...
'style', 'edit', ...
'Units', 'normalized', ...
'Position', [0.0 0.25 0.8 0.2], ...
'HorizontalAlignment', 'left', ...
'String', config_file);
buttonBrowserConfigFile = uicontrol('Parent', d, ...
'style', 'pushbutton', ...
'Units', 'normalized', ...
'Position', [0.8 0.25 0.2 0.2], ...
'String', 'browser', ...
'callback', @onBrowserConfigFile);
pushbuttonOk = uicontrol('Parent', d,...
'Style','pushbutton',...
'Units', 'normalized', ...
'Position', [0.2 0.05 0.15 0.15], ...
'String', 'Ok', ...
'callback', @onOk);
pushbuttonCancel = uicontrol('Parent', d,...
'Style','pushbutton',...
'Units', 'normalized', ...
'Position', [0.6 0.05 0.15 0.15], ...
'String', 'Cancel', ...
'Callback', 'delete(gcf)');
function onBrowserDataRootFolder(src, event)
% get the dir to load the images
folder_name = uigetdir(current_file_path, 'Select the data root directory');
if isequal(folder_name, 0)
disp('user selected cancel');
return;
else
disp(['user selected ', folder_name]);
data_root = folder_name;
% update the edit box
set(editBoxDataRootFolder, 'String', data_root);
% update the config file
config_file = [data_root '/' 'camera_lidar_calibration_config.yml'];
set(editBoxConfigFile, 'String', config_file);
end
end % onBrowserDataRootFolder
function onBrowserConfigFile(src, event)
[FileName, PathName] = uigetfile('*.yml', 'load the config file', data_root);
if isequal(FileName, 0)
disp('user selected cancel');
return;
else
disp(['user selected ', [PathName FileName]]);
end
config_file = [PathName FileName];
set(editBoxConfigFile, 'String', config_file);
end % onBrowserConfigFile
function onOk(src, event)
% delete the figure
delete(gcf);
chessboard_camera_lidar_calibration(current_file_path, data_root, config_file);
end % onOk
end
end