%%   MASTER THESIS   %%
%==================== %
%        JOÃO PEIXOTO %
%               60140 %
%  joao.peixoto@ua.pt %
%                2016 %
%==================== %


%% CHAPTER 5 - KALMAN FILTER

%     This script will execute all the image acquisition process for
% different values of angle_tol, which will give different feature sized
% outputs. The purpose is to try to obtain a relation between the number of
% features measured VS the quality of the Kalman Filter output.


%% 00 Clean Workspace and Global Variables
% First, we need to clear the workspace and then define some global
% variables, which will decide on the script behaviour.
for chapter = 0:0
    % Space Cleaning
    clc
    clear all
    close all
    % Configuration Loading
    config1 = CONFIG_DATA_1;
    config2 = CONFIG_DATA_2;
end
%% 01 Image Acquisition Process
% In this chapter we will obtain the output from the same set of frames but
% with different angle_tol values.
for chapter = 1:1
    % angleTol values to be tested
    a = 0:0.50:2.5;
    for i = 1:size(a,2)
        % for both experiments
        fprintf('Starting number %d of %d which is %0.2f.\n',i,size(a,2),a(i))
        for exp = 1:2
            fprintf('Experiment #%d\n',exp)
            config1(17,1) = a(i);   % angle_tol
            % output acquisition
            ImageSolution = function_CreateFeatureVisualData(config1, exp);
%             maxValue = 0;
%             for b = 1:size(ImageSolution,2); if(sum(ImageSolution(1:10,b)) == 0 && maxValue == 0); maxValue = b; end; end
%             ImageSolution(:,maxValue:end) = [];
            % saving the acquired data with the name: expA_Tol_B.BB.mat,
            % where:    A is the experiment number and
            %           B is the angle_tol value.
            save(sprintf('exp%d_Tol%0.2f.mat', exp, a(i)),'ImageSolution');
        end
        fprintf('Ended.\n\n***\n\n')
    end
end