Re: Scanning detailed QR code in paper scanned PDF

872 views
Skip to first unread message

Sean Owen

unread,
Jun 4, 2013, 12:04:32 PM6/4/13
to zx...@googlegroups.com
You really have to provide an image when you ask questions like this.
C# is not supported here anymore but you can look at ZXing .NET

kenji uno

unread,
Jun 4, 2013, 7:28:47 PM6/4/13
to zx...@googlegroups.com
Thanks for your reply!

About an image, I'll prepare alternative one. The real one is sensitive information.

I love C# support in zxing, I'll check ZXing .NET later.

Thanks.

2013年6月5日水曜日 1時04分32秒 UTC+9 Sean Owen:

kenji uno

unread,
Jun 4, 2013, 8:44:40 PM6/4/13
to zx...@googlegroups.com
Here is my sample for public use (no secret included).

The one is pure symbol generated by libqrencode, another one is paper scanned symbol from printed paper by TOSHIBA MFP.

Both ZXing .NET r86397 and ZXing 2.2 javase didn't recognize the scanned symbol.

I'll talk about my consideration about improving readability, later.

Thanks

2013年6月5日水曜日 1時04分32秒 UTC+9 Sean Owen:
You really have to provide an image when you ask questions like this.

kenji uno

unread,
Jun 4, 2013, 9:24:38 PM6/4/13
to zx...@googlegroups.com
I tried these methods.

For input images:
  1. No manipulation
  2. ImageMagick -blur 2.0
  3. ImageMagick -resize 150%
For Detector:
  • AlignmentPatternFinder: maxVariance / 2.0f to 1.5f.
  • Tweak calculateModuleSize: detect correct module size by reading horz and vert timing lines.
For DefaultGridSampler:
  • Tweak the sampling points by reading horz and vert timing lines.

I know that these changes will not meet with zxing's goal (barcode reader for the mobile phones). And it won't be back ported to zxing project.
However I'm very pleased to know these methods work fine for me. (It was yesterday that I have finished tweaking DefaultGridSampler)

Thanks.

2013年6月5日水曜日 9時44分40秒 UTC+9 kenji uno:

Sean Owen

unread,
Jun 4, 2013, 10:24:35 PM6/4/13
to zx...@googlegroups.com
I see. Yes the 'pure' barcode decodes fine so it is a question of detection. It will be a little challenging given the distortion here but looks possible.

I don't think that blur/resize probably helps here. I would turn on "try harder" mode as a hint, and I would also try enabling the other binarizer class.

Since you may have easy access to a debugger, I would look to see whether it is finding the alignment patterns correctly or not. That would at least help narrow down the part of the detection that fails.

kenji uno

unread,
Jun 6, 2013, 1:53:16 AM6/6/13
to zx...@googlegroups.com
For your information:

Here is detected symbol brought by zxing javase. The output is 125x125. The expected size is 129x129.

It will need tweak for detector.



2013年6月5日水曜日 11時24分35秒 UTC+9 Sean Owen:

kenji uno

unread,
Jun 6, 2013, 2:25:08 AM6/6/13
to zx...@googlegroups.com

The output is now 129x129. Using timing line. However it fully depends on how symbol is clearly scanned.

I'll also attach the Detector's patch. But it is test code, I don't think it is product quality code.

Thanks.



2013年6月6日木曜日 14時53分16秒 UTC+9 kenji uno:
zxing_tweak.patch

Sean Owen

unread,
Jun 6, 2013, 7:40:57 AM6/6/13
to zx...@googlegroups.com
This symbol looks distorted by scaling. Are you sure you aren't scaling this incorrectly because you're not accounting for the require 4-module quiet zone around the edge?

Sean Owen

unread,
Jun 6, 2013, 7:42:14 AM6/6/13
to zx...@googlegroups.com
This is a correct image, and it is scanned by the project. What needs a patch then? does this enable scanning your original scanned image?
Yes it would be better to see a more targeted patch with explanation.

kenji uno

unread,
Jun 6, 2013, 10:19:51 PM6/6/13
to zx...@googlegroups.com
Sorry. I'm very slovenly. I need to report in detail.

---

I proposed the scanned image for discussion with practical usage of zxing.

I prepared a dummy order sheet with a 35mm long QR symbol. It is printed and scanned by 300dpi. (I prepared similar dummy one because the real sheet cannot be attached)

The symbol size is around 416 by 416 pixels. 416[dots] / 300[dpi] -> 1.386[inch] -> 35.22[mm]

That distortion might have been added during optical scan by MFP.

---

The pure QR symbol is 129 by 129 pixels as you now.

I tried to decode the "optically scanned" QR symbol with zxing 2.2 javase version. Unfortunately, it said:

file:/C:/A/QR_28_L_Paper_scan.png: No barcode found

I modified zxing to write down the detected symbol. It was 125 by 125 pixels long.

---

Then I have injected my code into Detector. It scans 2 timing lines. It helped this case. We got 129 by 129 image, with 0.5% error.

zxing have successfully decoded at last.

file:/C:/A/QR_28_L_Paper_scan.png (format: QR_CODE, type: TEXT):
Raw result:
OrderSheet  Supplier+++++++++++++++++++++++++++++++++++++++++++E  12345  Manufacturer1234567890+++++++++++++E Manufacturer1234567890+++++++++++++E Manufacturer1234567890+++++++++++++E Manufacturer1234567890+++++++++++++E Manufacturer1234567890+++++++++++++E Manufacturer1234567890+++++++++++++E Manufacturer1234567890+++++++++++++E Manufacturer1234567890+++++++++++++E   Parts+++++++++++++++++++++++++++++++++++++++++++++E Parts+++++++++++++++++++++++++++++++++++++++++++++E Parts+++++++++++++++++++++++++++++++++++++++++++++E Parts+++++++++++++++++++++++++++++++++++++++++++++E Parts+++++++++++++++++++++++++++++++++++++++++++++E Parts+++++++++++++++++++++++++++++++++++++++++++++E Parts+++++++++++++++++++++++++++++++++++++++++++++E Parts+++++++++++++++++++++++++++++++++++++++++++++E?@  Unitobj+++++++++++++++++++++++++++++++++++++++++E?@Unitobj+++++++++++++++++++++++++++++++++++++++++E?@Unitobj+++++++++++++++++++++++++++++++++++++++++E?@Unitobj+++++++++++++++++++++++++++++++++++++++++E?@Unitobj+++++++++++++++++++++++++++++++++++++++++E?@Unitobj+++++++++++++++++++++++++++++++++++++++++E?@Unitobj+++++++++++++++++++++++++++++++++++++++++E?@Unitobj+++++++++++++++++++++++++++++++++++++++++E   Metrics ABCDEF XYZXYZXYZ+++++++++++++++++++++E TEST+A+++++A Coop+++++++++++++++++++++++++++++++++++++++++++ESir Memo++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++E?@  2013/06/05
Parsed result:
OrderSheet  Supplier+++++++++++++++++++++++++++++++++++++++++++E  12345  Manufacturer1234567890+++++++++++++E Manufacturer1234567890+++++++++++++E Manufacturer1234567890+++++++++++++E Manufacturer1234567890+++++++++++++E Manufacturer1234567890+++++++++++++E Manufacturer1234567890+++++++++++++E Manufacturer1234567890+++++++++++++E Manufacturer1234567890+++++++++++++E   Parts+++++++++++++++++++++++++++++++++++++++++++++E Parts+++++++++++++++++++++++++++++++++++++++++++++E Parts+++++++++++++++++++++++++++++++++++++++++++++E Parts+++++++++++++++++++++++++++++++++++++++++++++E Parts+++++++++++++++++++++++++++++++++++++++++++++E Parts+++++++++++++++++++++++++++++++++++++++++++++E Parts+++++++++++++++++++++++++++++++++++++++++++++E Parts+++++++++++++++++++++++++++++++++++++++++++++E?@  Unitobj+++++++++++++++++++++++++++++++++++++++++E?@Unitobj+++++++++++++++++++++++++++++++++++++++++E?@Unitobj+++++++++++++++++++++++++++++++++++++++++E?@Unitobj+++++++++++++++++++++++++++++++++++++++++E?@Unitobj+++++++++++++++++++++++++++++++++++++++++E?@Unitobj+++++++++++++++++++++++++++++++++++++++++E?@Unitobj+++++++++++++++++++++++++++++++++++++++++E?@Unitobj+++++++++++++++++++++++++++++++++++++++++E   Metrics ABCDEF XYZXYZXYZ+++++++++++++++++++++E TEST+A+++++A Coop+++++++++++++++++++++++++++++++++++++++++++ESir Memo++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++E?@  2013/06/05
Found 4 result points.
 
Point 0: (78.0,472.0)
 
Point 1: (76.5,78.5)
 
Point 2: (464.5,76.0)
 
Point 3: (456.25,460.0)


---

In my real case, I needed to tweak DefaultGridSampler too. In this case, it is not needed.

Thanks

2013年6月6日木曜日 20時42分14秒 UTC+9 Sean Owen:
Reply all
Reply to author
Forward
0 new messages