-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathiterative_calib.m
109 lines (74 loc) · 3.29 KB
/
iterative_calib.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
options = calibrate_options();
%% iterative calibration
global dataset_path conf_grid_p conf_grid_x depth_plane_points depth_plane_disparity calib0
global dfiles rgb_grid_p
global corner_count_x corner_count_y dx
if isempty(dfiles)
%if needed, select images
do_select_images_Intel(options);
end
do_process_depth_regions(options);
%save all markups
do_initial_calib_intel(options);
fprintf('Initial Calibration - done\n');
fprintf('Saving the variables \n');
save([dataset_path '/markup.mat'],'conf_grid_p','conf_grid_x',...
'depth_plane_mask','rgb_grid_p','rgb_grid_x',...
'corner_count_x','corner_count_y','dx',...
'rfiles','dfiles','cfiles');
%c = calib0;
errors = [];
iter = 0;
calib = calib0;
if(options.color_present)
[cost,comp] = calibrate_intel_cost(calib,depth_plane_points,depth_plane_disparity,conf_grid_x,conf_grid_p,options,rgb_grid_p{1});
if(options.depth_in_calib)
calib.sigma_dplane = std(cost(comp=='P'))*sqrt(sum(comp=='P'))/1; %underweight depth points
else
calib.sigma_dplane = 1;
end
calib.sigma_dcorners = std(cost(comp=='C'))*sqrt(sum(comp=='C'))/10;
calib.sigma_rgb = std(cost(comp=='R'))*sqrt(sum(comp=='R'))/10;
else
[cost,comp] = calibrate_intel_cost(calib,depth_plane_points,depth_plane_disparity,conf_grid_x,conf_grid_p,options);
calib.sigma_dplane = std(cost(comp=='P'))*sqrt(sum(comp=='P'))/10;
calib.sigma_dcorners = std(cost(comp=='C'))*sqrt(sum(comp=='C'))/10;
calib.sigma_rgb = 1;
end
errors = [errors cost];
errors(comp=='P',:) = errors(comp=='P',:)/calib.sigma_dplane;
errors(comp=='C',:) = errors(comp=='C',:)/calib.sigma_dcorners;
errors(comp=='R',:) = errors(comp=='R',:)/calib.sigma_rgb;
c = calibrate_intel(options,calib);
%eval = do_eval(c,options);
%[cost,comp] = calibrate_intel_cost(c,depth_plane_points,depth_plane_disparity,conf_grid_x,conf_grid_p,options,rgb_grid_p{1});
%errors = [errors cost];
%corr = [];
%corr_points = 500:10:2000;
if(options.depth_in_calib && options.correct_depth)
calib = fit_depth_correction(c);
%corr = [corr; gaussian_kern_reg(corr_points,calib.inputs,calib.res, calib.h)];
%eval = do_eval(calib,options,eval);
%[cost,comp] = calibrate_intel_cost(calib,depth_plane_points,depth_plane_disparity,conf_grid_x,conf_grid_p,options,rgb_grid_p{1});
%errors = [errors cost];
while(iter < options.max_iter-1)
c = calibrate_intel(options,calib);
%eval = do_eval(c,options,eval);
%[cost,comp] = calibrate_intel_cost(c,depth_plane_points,depth_plane_disparity,conf_grid_x,conf_grid_p,options,rgb_grid_p{1});
%errors = [errors cost];
calib = fit_depth_correction(c);
%corr = [corr; gaussian_kern_reg(corr_points,calib.inputs,calib.res, calib.h)];
%eval = do_eval(calib,options,eval);
if(options.color_present)
cost = calibrate_intel_cost(calib,depth_plane_points,depth_plane_disparity,conf_grid_x,conf_grid_p,options,rgb_grid_p{1});
else
[cost,comp] = calibrate_intel_cost(calib,depth_plane_points,depth_plane_disparity,conf_grid_x,conf_grid_p,options);
end
%if(options.eval)
errors = [errors cost];
%end
iter = iter +1;
end
else
calib = c;
end