Usual algorithms for detecting the presence of a QR-code in an image seem to have trouble detecting a code when it is tilted (especially at 45°). This is dependent on the resolution as well. The following shows the issue

DynamicModule[{img, res, img2},
img = BarcodeImage[
        "This is a very long sentence \n
         meant to include lots  \n 
         and \lots and lots  \n 
         and lots and lots and lots \n 
         of bits of information to showcase the issue.", {"QR", "H"}] 
// Rasterize[#, RasterSize -> size] &;

res = (img2 = img // ImageRotate[#, \[Alpha], Background -> None] &) 
//BarcodeRecognize[#, "Data", "QR"] &;

Column[{"Angle: " <> ToString[\[Alpha]*360/(2 \[Pi])], img2, 
res}], {\[Alpha], 0, 360 \[Degree] }, {size, 180, 200, 1}]

enter image description here

From this Q&A I know that Mathematica internally use ZXing for processing QR-codes. Supposedly this library supports a "TryHarder" flag to deal with such issues by trying e.g. a rotated version of the image as well (see here).

Can one access these settings via Mathematica's BarcodeRecognize as well?

  • 1
    $\begingroup$ Probably not what you are looking for, but you have access to all the classes in ZXing. decoder = JavaNew["com.google.zxing.qrcode.decoder.Decoder"] will create a new java object. So you could roll your own decoding function. $\endgroup$ – Jason B. Dec 6 '17 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.