ingest-file icon indicating copy to clipboard operation
ingest-file copied to clipboard

Add barcode detection to OCR

Open josegomezr opened this issue 5 months ago • 1 comments

LocalOCRService can now detect 1D barcodes and QR Codes via pyzbar.

In our investigations we've realized that QR detection can be impaired if the QR Code contain artifacts/noise within the code. We've included a parametrizable processing pipeline to minimize artifacts and improve the scanner performance.

Before (not detected by zbar): image

After (detected): image

The results of pyzbar are appended at the end of the OCR output in the form of:

--- QRCODE CODE ---
QUALITY: 1
ORIENTATION: UP
POSITION: [278, 18549, 1352, 1386]
DATA: 190401021.01.1.0001!54,3,0,0,2,0,0,0,3,0,0,1,4,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,2,2,68,1,0!0!0

Note: result extracted from the sample images above

We have some preliminary timings as well as part of this change. In a best-case scenario (pyzbar finds codes at first try) it'll take ~450ms more than current master, and if it needs to go over the processing pipeline every attempt takes ~1.5s.

Using python-opencv and numpy improve the speed of the image filters, but we wanted to keep the changes at minimum first.

Open Questions:

  • [ ] Are log messages ok?
  • [ ] Is the logic aligned with your style? I tried my best to match it

josegomezr avatar Aug 31 '24 08:08 josegomezr