clc
clear all
close all


vis = false    
% visualizacao gráficos on/off
nimg = 10;              
% número imagens padrão
grao = 'P2500'
% padrão a gravar
pds = [' a';' b';' c';' d';' e';' f';' g';' h';' i';' j';' l';' m';' n';' o';' p'];
% padrões alternativos ou amostras
spc = [' aa';' bb';' cc';' dd';' ee';' ff';' gg';' hh';' ii';' jj';' ll';' mm';' nn';' oo';' pp'];
%spc = ['ar';'br';'cr';'dr';'er';'fr';'gr';'hr';'jr';'lr';'mr';'nr';'or';'pr'];
%fgs = ['FG1';'FG2';'FG3';'FG4';'FG5';'FG6';'FG7';'FG8';'FG9'];

caminho = 'C:\Programas\MATLAB71\work\Ensaios Mestrado - 05.05.08\Imagens 2ºparte Trabalho\04.02.09 - Comparação_PadrãoActual_PadrãoAntigo_Recolha\';
dttlx = '\030209 L AGUA RL ';
   
mtrcsf = 100;
while mtrcsf ~= NaN
    iadq =aquisicaoim;    
    vecfoca =  verificafoca(iadq, vis)
    Pvecfoca = [4.2911 9.2944 0.0013 0.0709 0.2742 2.6457 0.8000 0 0.2000 0 0 0 0 0]
    somaf =0;
    for i = 1:10
        somaf = somaf + (Pvecfoca(i) - vecfoca(i))^2;
        mtrcsf = sqrt(somaf);
    end
    figure(1)
    imshow(iadq)
    text(150,72,int2str(mtrcsf),'Color','y',...
    'FontWeight', 'bold');
end

for t = 1:10
    
    iadq =aquisicaoim;    
    vecam =leituraAmostra2(iadq, vis);
    
    if t==1
        Pvecam = vecam;
    end
    soma =0;
    
    for i = 1:10
        soma = soma + (Pvecam(i) - vecam(i))^2;
        mtrcs = sqrt(soma);
    end
    
    
    figure(1)
    imshow(iadq)
    text(150,72,'5 segundos','Color','y',...
    'FontWeight', 'bold');
    text(150,100,int2str(mtrcs),'Color','y',...
    'FontWeight', 'bold');
    text(150,128,int2str(mtrcsf),'Color','y',...
    'FontWeight', 'bold');
    pause(1);
    figure(1)
    imshow(iadq)
    text(150,72,'4 segundos','Color','y',...
    'FontWeight', 'bold');
    text(150,100,int2str(mtrcs),'Color','y',...
    'FontWeight', 'bold');
    text(150,128,int2str(mtrcsf),'Color','y',...
    'FontWeight', 'bold');
    pause(1);
    figure(1)
    imshow(iadq)
    text(150,72,'3 segundos','Color','y',...
    'FontWeight', 'bold');
    text(150,128,int2str(mtrcsf),'Color','y',...
    'FontWeight', 'bold');
    text(150,100,int2str(mtrcs),'Color','y',...
    'FontWeight', 'bold');
    text(150,128,int2str(mtrcsf),'Color','y',...
    'FontWeight', 'bold');
    pause(1);
    figure(1)
    imshow(iadq)
    text(150,72,'2 segundos','Color','y',...
    'FontWeight', 'bold');
    text(150,100,int2str(mtrcs),'Color','y',...
    'FontWeight', 'bold');
    text(150,128,int2str(mtrcsf),'Color','y',...
    'FontWeight', 'bold');
    pause(1);
    figure(1)
    imshow(iadq)
    text(150,72,'1 segundo','Color','y',...
    'FontWeight', 'bold');
    text(150,100,int2str(mtrcs),'Color','y',...
    'FontWeight', 'bold');
    text(150,128,int2str(mtrcsf),'Color','y',...
    'FontWeight', 'bold');
    pause(1);
    figure(1)
    imshow(iadq)
    text(150,72,'A ADQUIRIR','Color','y',...
    'FontWeight', 'bold');
    text(150,100,int2str(mtrcs),'Color','y',...
    'FontWeight', 'bold');
    text(150,128,int2str(mtrcsf),'Color','y',...
    'FontWeight', 'bold');
    
     
    fn = strcat(caminho, grao);
    fn = [fn dttlx grao pds(t,:) '.jpg']
    
    %imwrite(iadq,fn);
    t = t +1;
end
        
        
        
