% 
% cam = webcam('USB Camera');
% preview(cam);
% pause();
% N = 30;
% Delay = 5;
% for i = 1:N   
%     fprintf('Taking snap %d\n',i);
%     I{i} = snapshot(cam);
%     
%     for j = 1:5
%         fprintf('Move checkerboard - %d/%d\n',j,Delay)
%         pause(1)
%     end
% end
% clear cam;
% 
% figure;
% 
% for i =1:length(I)
% imshow(I{i}),shg,drawnow;
% pause()   
% end
% 
% 
a = 0;
cfolder = pwd;
 for i =1:length(I)
     
     if ~isempty(I{i})
         a = a+1;
        s = strcat('img',num2str(a));
        s = strcat(s,'.png');
        imwrite(I{i},fullfile(cfolder,'camCalibration',s))
     end
end

