%1- Calibration: Get the of the source light, and the camera calib parameters. calib_name = input('Calibration image name? ([]=no image calibration) ','s'); if ~isempty(calib_name), if exist(calib_name), % Ic = readras(calib_name); Ic = imread(calib_name,'bmp'); Ic = double(Ic(:,:,2)); [omc,Rc,Tc,fc,cc,kc,exc] = AutoCalibCam(Ic,gray(256)); % Normal of the calibration plane, and distance: pc = [Rc(:,3); -Rc(:,3)'*Tc]; n_ground = pc(1:3); d_ground = -pc(4); omega_ground = n_ground / d_ground; dd = -pc(4); nd = pc(2:3)/norm(pc(2:3)); theta = atan2(nd(2),nd(1)); % tilt angle on the camera disp('Save the camera calibration under calib_camera.mat'); save calib_camera omc Rc Tc fc cc kc pc theta dd n_ground d_ground omega_ground exc else error('This images does not exist'); end; end; q_light = input('Need to calibrate the light source? ([]=no) '); if ~isempty(q_light), calib_light; % the saving is inside the function end;