Code covered by the BSD License  

Highlights from
Aztec barcode reader

image thumbnail

Aztec barcode reader

by

 

This program can read Aztec barcode from video or pictures. It is partial in Dutch

[rij,colom,kans_op_correct_middelpunt,type]=middel(binair, zbinair)
function [rij,colom,kans_op_correct_middelpunt,type]=middel(binair, zbinair)
patroon=[1,1,2,2,2,2,2,2,2,0,1;
         1,1,1,1,1,1,1,1,1,1,1;
         2,1,0,0,0,0,0,0,0,1,2;
         2,1,0,1,1,1,1,1,0,1,2;
         2,1,0,1,0,0,0,1,0,1,2;
         2,1,0,1,0,1,0,1,0,1,2;
         2,1,0,1,0,0,0,1,0,1,2;
         2,1,0,1,1,1,1,1,0,1,2;
         2,1,0,0,0,0,0,0,0,1,2;
         0,1,1,1,1,1,1,1,1,1,1;
         0,0,2,2,2,2,2,2,2,0,0];

patroonl=[1,1,2,2,2,2,2,0,2,2,2,2,2,0,1
        1,1,1,1,1,1,1,1,1,1,1,1,1,1,1;
        2,1,0,0,0,0,0,0,0,0,0,0,0,1,2;
        2,1,0,1,1,1,1,1,1,1,1,1,0,1,2;
        2,1,0,1,0,0,0,0,0,0,0,1,0,1,2;
        2,1,0,1,0,1,1,1,1,1,0,1,0,1,2;
        2,1,0,1,0,1,0,0,0,1,0,1,0,1,2;
        0,1,0,1,0,1,0,1,0,1,0,1,0,1,0;
        2,1,0,1,0,1,0,0,0,1,0,1,0,1,2;
        2,1,0,1,0,1,1,1,1,1,0,1,0,1,2;
        2,1,0,1,0,0,0,0,0,0,0,1,0,1,2;
        2,1,0,1,1,1,1,1,1,1,1,1,0,1,2;
        2,1,0,0,0,0,0,0,0,0,0,0,0,1,2;
        0,1,1,1,1,1,1,1,1,1,1,1,1,1,1;
        0,0,2,2,2,2,2,2,2,2,2,2,2,0,0];

kansen=[];
type=1;

for r=6:(zbinair(1)-6)
    for c=6:(zbinair(2)-6)
        kans=0;
        for a=1:11
            for b=1:11
                if patroon(a,b)==2
                elseif patroon(a,b)==1 && binair((r+a-6),(c+b-6))==0
                    kans=kans+1;
                elseif patroon(a,b)==0 && binair((r+a-6),(c+b-6))==1
                    kans=kans+1;
                end
            end
        end
        kansen(r,c)=kans;
    end
end
mkans=max(max(kansen));
kans_op_correct_middelpunt=mkans/93*100;
zkans=size(kansen);
rij=0;
nrij=1;
colom=0;
while rij==0 && nrij<=zkans(1)
    for a=1:zkans(2)
        if kansen(nrij,a)==mkans
            rij=nrij;
            colom=a;
        end
    end
    nrij=nrij+1;
end

kansl=0;
if rij>8 && colom>8 && (rij+7)<zbinair(1) && (colom+7)<zbinair(2)
for a=1:15
    for b=1:15
         if patroonl(a,b)==2
         elseif patroonl(a,b)==1 && binair((rij+a-8),(colom+b-8))==0
              kansl=kansl+1;
         elseif patroonl(a,b)==0 && binair((rij+a-8),(colom+b-8))==1
              kansl=kansl+1;
         end
     end
end
end
if kansl>178 %max is 184
    type=2;
    kans_op_correct_middelpunt=kansl/184*100;
end
                    
        

Contact us