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,raster,gegevens,lagenR]=uitlezenk(binair, zbinair, middelpunt)
function [rij,raster,gegevens,lagenR]=uitlezenk(binair, zbinair, middelpunt)
schema=[609,608,411,413,415,417,419,421,423,425,427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459; 
    607,606,410,412,414,416,418,420,422,424,426,428,430,432,434,436,438,440,442,444,446,448,450,452,454,456,458;
	605,604,409,408,243,245,247,249,251,253,255,257,259,261,263,265,267,269,271,273,275,277,279,281,283,460,461;
	603,602,407,406,242,244,246,248,250,252,254,256,258,260,262,264,266,268,270,272,274,276,278,280,282,462,463;
	601,600,405,404,241,240,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,284,285,464,465;
	599,598,403,402,239,238,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,286,287,466,467;
	597,596,401,400,237,236,105,104,3,5,7,9,11,13,15,17,19,21,23,25,27,140,141,288,289,468,469;
	595,594,399,398,235,234,103,102,2,4,6,8,10,12,14,16,18,20,22,24,26,142,143,290,291,470,471;
	593,592,397,396,233,232,101,100,1,1,2000,2001,2002,2003,2004,2005,2006,0,1,28,29,144,145,292,293,472,473;
	591,590,395,394,231,230,99,98,1,1,1,1,1,1,1,1,1,1,1,30,31,146,147,294,295,474,475;
	589,588,393,392,229,228,97,96,2027,1,0,0,0,0,0,0,0,1,2007,32,33,148,149,296,297,476,477;
	587,586,391,390,227,226,95,94,2026,1,0,1,1,1,1,1,0,1,2008,34,35,150,151,298,299,478,479;
	585,584,389,388,225,224,93,92,2025,1,0,1,0,0,0,1,0,1,2009,36,37,152,153,300,301,480,481;
	583,582,387,386,223,222,91,90,2024,1,0,1,0,1,0,1,0,1,2010,38,39,154,155,302,303,482,483;
	581,580,385,384,221,220,89,88,2023,1,0,1,0,0,0,1,0,1,2011,40,41,156,157,304,305,484,485;
	579,578,383,382,219,218,87,86,2022,1,0,1,1,1,1,1,0,1,2012,42,43,158,159,306,307,486,487;
	577,576,381,380,217,216,85,84,2021,1,0,0,0,0,0,0,0,1,2013,44,45,160,161,308,309,488,489;
	575,574,379,378,215,214,83,82,0,1,1,1,1,1,1,1,1,1,1,46,47,162,163,310,311,490,491;
	573,572,377,376,213,212,81,80,0,0,2020,2019,2018,2017,2016,2015,2014,0,0,48,49,164,165,312,313,492,493;
	571,570,375,374,211,210,78,76,74,72,70,68,66,64,62,60,58,56,54,50,51,166,167,314,315,494,495;
	569,568,373,372,209,208,79,77,75,73,71,69,67,65,63,61,59,57,55,52,53,168,169,316,317,496,497;
	567,566,371,370,206,204,202,200,198,196,194,192,190,188,186,184,182,180,178,176,174,170,171,318,319,498,499;
	565,564,369,368,207,205,203,201,199,197,195,193,191,189,187,185,183,181,179,177,175,172,173,320,321,500,501;
	563,562,366,364,362,360,358,356,354,352,350,348,346,344,342,340,338,336,334,332,330,328,326,322,323,502,503;
	561,560,367,365,363,361,359,357,355,353,351,349,347,345,343,341,339,337,335,333,331,329,327,324,325,504,505;
	558,556,554,552,550,548,546,544,542,540,538,536,534,532,530,528,526,524,522,520,518,516,514,512,510,506,507;
	559,557,555,553,551,549,547,545,543,541,539,537,535,533,531,529,527,525,523,521,519,517,515,513,511,508,509
];

A=[middelpunt(1) middelpunt(2) (zbinair(1)-middelpunt(1)+1) (zbinair(2)-middelpunt(2)+1)];
B=min(A);
raster=zeros(zbinair(1),zbinair(2));
if B<8
    %msgbox('barcode is te klein');
elseif B<10
    schema=schema(7:21,7:21);
    schema(1,1:2)=0;
    raster((middelpunt(1)-7):(middelpunt(1)+7),(middelpunt(2)-7):(middelpunt(2)+7))=schema;
elseif B<12
    raster((middelpunt(1)-9):(middelpunt(1)+9),(middelpunt(2)-9):(middelpunt(2)+9))=schema(5:23,5:23);
elseif B<14
    schema=schema(3:25,3:25);
    raster((middelpunt(1)-11):(middelpunt(1)+11),(middelpunt(2)-11):(middelpunt(2)+11))=schema;
elseif B<16
    raster((middelpunt(1)-13):(middelpunt(1)+13),(middelpunt(2)-13):(middelpunt(2)+13))=schema;
else
    %msgbox('barcode is te groot');
end

rij=[];
gegevens=[];

for h=1:zbinair(2)
    for v=1:zbinair(1)
        if raster(v,h)>=2000
            if binair(v,h)==1
                gegevens(raster(v,h)-1999)=0;
            else
                gegevens(raster(v,h)-1999)=1;
            end
        elseif raster(v,h)>1
            rij(raster(v,h))=binair(v,h);
            raster(v,h)=binair(v,h);
        elseif raster(v,h)==0
            raster(v,h)=0.2;
        else
            raster(v,h)=0;
        end
    end
end

lagenR=floor((B-6)/2);

%afkappen tot geldige code
if size(rij)>0
    rij(1)=[];
end


Contact us