/
do_select_planes_Intel.m
71 lines (61 loc) · 1.74 KB
/
do_select_planes_Intel.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
%do_select_planes()
% UI function.
% Kinect calibration toolbox by DHC
function do_select_planes_Intel()
%Input
global dataset_path dfiles
%Output
global depth_plane_poly depth_plane_mask
%width = 640;
%height = 480;
Id = imread([dataset_path '/' dfiles{1}]);
width = size(Id,2);
height = size(Id,1);
icount = length(dfiles);
fprintf('-------------------\n');
fprintf('Selecting planes\n');
fprintf('-------------------\n');
%Select images
if(isempty(depth_plane_poly))
depth_plane_poly = cell(1,icount);
depth_plane_mask = cell(1,icount);
fidx = 1:icount;
else
%Check for too small or too big array
if(length(depth_plane_poly) < icount)
depth_plane_poly{icount} = [];
depth_plane_mask{icount} = [];
elseif(length(depth_plane_poly) > icount)
depth_plane_poly = depth_plane_poly(1:icount);
depth_plane_mask = depth_plane_mask(1:icount);
end
%Select only missing planes
missing = cellfun(@(x) isempty(x),depth_plane_poly) & ~cellfun(@(x) isempty(x),dfiles);
if(all(missing))
default = 1:length(dfiles);
fidx = input('Select images to process ([]=all): ');
else
default = find(missing);
fidx = input(['Select images to process ([]=[' num2str(default) ']): ']);
end
if(isempty(fidx))
fidx = default;
end
end
%Get plane polygons for all images
[uu,vv] = meshgrid(0:width-1,0:height-1);
for i=fidx
if(isempty(dfiles{i}))
continue
end
fprintf('#%d - %s\n',i,dfiles{i});
imd = read_disparity([dataset_path dfiles{i}],0);
depth_plane_poly{i} = select_plane_polygon(imd);
%Extract mask
if(isempty(depth_plane_poly{i}))
depth_plane_mask{i} = false(size(imd));
else
depth_plane_mask{i} = inpolygon(uu,vv,depth_plane_poly{i}(1,:),depth_plane_poly{i}(2,:));
end
end
fprintf('Done\n');