Spelt / ZXing.Delphi

ZXing Barcode Scanning object Pascal Library for Delphi VCL and Delphi Firemonkey
Apache License 2.0
471 stars 206 forks source link

QR code detector susceptible to noise in scanned images #110

Closed sboydlns closed 3 years ago

sboydlns commented 3 years ago

I have found that the crossCheck* routines in FinderPatternFinder.pas are VERY sensitive to noise in the scanned image. I am talking about B&W TIFF images on Windows systems. Each of these methods only scan a single line of bits in order to cross check the validity vertically, horizontally or diagonally. A single white pixel in an otherwise black field (or vice versa) will cause any of these methods to fail.

To get around this, I have modified the code to scan 3 lines, centered on the requested line. If any of these lines are valid I assume that the QR code is valid. This seems to work for me.

Any suggestions or concerns with what I have done?

BTW I am using version 3.5

Steve Boyd

Spelt commented 3 years ago

Sounds very nice. Do you have a link to the code and a failing test case?

Op do 24 sep. 2020 om 21:46 schreef sboydlns notifications@github.com:

I have found that the crossCheck* routines in FinderPatternFinder.pas are VERY sensitive to noise in the scanned image. I am talking about B&W TIFF images on Windows systems. Each of these methods only scan a single line of bits in order to cross check the validity vertically, horizontally or diagonally. A single white pixel in an otherwise black field (or vice versa) will cause any of these methods to fail.

To get around this, I have modified the code to scan 3 lines, centered on the requested line. If any of these lines are valid I assume that the QR code is valid. This seems to work for me.

Any suggestions or concerns with what I have done?

BTW I am using version 3.5

Steve Boyd

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Spelt/ZXing.Delphi/issues/110, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADAS3VOHG6YV4N7WJIBLS4TSHOO3BANCNFSM4RYWOHYQ .

sboydlns commented 3 years ago

This archive contains the modified source and a sample image that fails using the original V3.5 source. I hope I attached the file properly.

zxing.zip

Spelt commented 3 years ago

Sorry for the delay, been busy.

Unfortunately there is a problem with your code, it breaks the unit tests. It will not scan some of the QR test images.

I hope you can find the time to fix it.

I also tested your tiff file and I can scan it without problems. Sometimes it depends also on the scan resolution. I do think your theory is sound and therefore I hope you can fix your patch.

Sincerely, Edward