Search code examples
c#.netqr-codezxing

Reading qr code with Zxing .Net 0.14.0.1 is not working when taking photo with camera


When reading a qr code that was generated via a qr code generator website and downloaded directly I am able to read the qr code with the following lines of code

 var reader = new BarcodeReader();
 reader.Options.TryHarder = true;
 reader.Options.PossibleFormats = new List<BarcodeFormat>();
 reader.Options.PossibleFormats.Add(BarcodeFormat.QR_CODE);
 var result = reader.Decode(new Bitmap(image));

This is working well for the following downloaded qr code

enter image description here

But it is not working for camera photos of the qr code like the following one

enter image description here

Even when I crop it it is not working

enter image description here

I have already tried downgrading to other versions as 0.14.0.1 and the other instructions from similar StackOverflow questions

I would appreciate your answer!


Solution

  • You have to downsize your qr code since the camera on you mobile may create photos that are so high in resolution that the library takes to long to process them and just timeouts.

    Try downsizing them to 512*512 before you process them.