Identification of a given barcode as either 1 D or 2 D
I think this is a fairly simple problem. Just compute the absolute gradient histogram (you, probably, don't even need to normalize). If it is concentrated around one angle, this should indicate a binary code, whereas more or less equally distributed histograms should be the opposite. Of course, this approach assumes that you always see barcode images, i.e. no negative class.

Ok, so I did a sample implementation for you, considering the above algorithm I described. Of course you could always make it better, but for the real-life images I tested, it gives reasonable results:

function [type] = classify_barcode_type(I, mingrad)

% convert to grayscale
if (size(I,3)&gt;1)
    I = rgb2gray(I);
end

% smooth the image
I = imgaussfilt(I, 2);

% compute sobel gradients
[Gmag,Gdir] = imgradient(I);

% upside down are the same (180 deg. range)
gdir = mod(Gdir+180,180);

% threshold the gradients: reduces noise
gradSelect = find(Gmag&gt;mingrad);
numGrad = length(gradSelect);

% histogram of gradients
[N, ~] = histcounts(gdir(gradSelect), 180);

% 'relMag' percent of the gradients are pointing towards a single dir.
relMag = max(N)./numGrad;

if (relMag&lt;0.05)
    type = 'qr';
else
    type = 'linear';
end

end


Sample images for an Aztec code and Code 128 barcode are as follows:




You could use the MATLAB function as follows:

% read the image
img = imread('real6s.png');

% apply custom rotation for robustness test
imgr=imrotate(img,125);

% classify
[type] = classify_1d_barcode(imgr, 40)


Note that, even though rotation creates many artificial edges, the approach remains to be robust, even in presence of severe rotations. In real life, you won't have the synthetic edges appearing due to rotations.

The figures below are plots of normalized gradient histograms ($\frac{\mathbf{N}}{\lVert \mathbf{N} \rVert}$ - also in the code). Note the difference between the aztec (QR) code and the linear barcode:



Note that linear barcode is rotated by 90 deg and this is clearly visible in the normalized angle histogram plot. You can get the rotation angle this way. Even though this example was for 90 deg rotation, you will get the same / similar results with any other rotation - theoretically the same results actually. Threshold (or the decision boundary) is indicated by the green line.