Library: Can't decode small Data Matrix (~10mm)

Created on 1 Nov 2018  路  13Comments  路  Source: zxing-js/library

Hello! I'm trying to use the library to scan a data matrix but I can't seem to get a read at all. It's all working fine for QR codes. I know in the Readme it mentions that there is no documentation for data matrix scanning.

Is there something different that I need to be doing in the setup?

Thanks!

question

Most helpful comment

Is there any progress in this issue?
We have same problem in our project.
The package fail with the small 2DMatrix codes, but you can't go closer with the camera, because the minimal focus distance.
Perhaps a Zoom option would be help on that?

All 13 comments

Are you using it on the browser?

Hi @odahcam - yes in browser, I've sort of got something working now - I was using "BrowserCodeReader"

I've swapped this out to use "BrowserDatamatrixCodeReader" now and I've managed to get it to read which is awesome!

Next question would be - what would be the recommended way of setting something that is happy to read multiple formats? Is there an example anywhere that I could use as a guide?

Thanks!
Giuseppe

Yeah, we've made an implementation of BrowserMultiFormatReader here: https://github.com/zxing-js/ngx-scanner/blob/master/src/app/modules/zxing-scanner/browser-multi-format-reader.ts

Please note that this code reader was made based on a custom BrowserCodeReader, so it may be different from the original here, I plan to bring these modification to the browser-layer in a near future.

To enable the multi format reading we use hints for this guy:

import { Result, DecodeHintType, BarcodeFormat } from '@zxing/library';

const formats =  [BarcodeFormat.QR_CODE, BarcodeFormat.DATA_MATRIX /* so on... */ ];

const hints = new Map<DecodeHintType, any>();

hints.set(DecodeHintType.POSSIBLE_FORMATS, formats);

const codeReader = new BrowserMultiFormatReader(hints);

Hope it helps!

Brilliant, thanks a lot @odahcam !

I hope you don't mind me throwing another quick question at you! I have it working well on a webcam, but on an iPhone there seems to be an issue with scanning the very small data matrix codes (they're tiny - around 10mm x 10mm). I think this could be something to do with the resolution of the iPhone camera being very high and the area of the rectangle being too small to be detected?

Thanks
Giuseppe

Thanks!

I never tryied to do something like that with the iPhone camera, but iPhone 8 always have some impressive results while scanning the QRs, I think the size vs. resolution should be the smaller of it's problems. 馃

What's the device you're testing on?

I'm using an iPhone 7. I have a slightly bigger matrix, maybe 15mm X 15mm that it reads okay. But the smaller version it doesn't work with at all.

I know that for QR codes, the minimum recomended size is of 20mm虏, maybe the same aplies to DataMatrix. If you're trying to read the code from a computer screen, well, I won't work at that size, but a physical DataMatrix at 10mm should be possible to decode.

I'm struggling to work this out @odahcam - on my webcam I can get a read, and on an iPad with a 6MP camera it'll work too, but on a 12MP iPhone camera it won't work at all.

Feels like it should be something to do with the area of detection and related to the resolution in some way?

Something in here?

https://github.com/zxing-js/library/blob/master/src/core/common/detector/WhiteRectangleDetector.ts

Well, this could be a bug, but to know that we gotta figure out how to test it first.

I found that if I comment out the code in WhiteRectangleDetector.js that is halving the size of the image (which is being done for performance reasons I assume)... and then hold very still with the barcode in the very centre of the image then it scans.

To test, all I did was create a few codes here:
https://barcode.tec-it.com/en/DataMatrix

Printed them, (they're actually 6mm X 6mm not 10mm) and created a quick browser based demo, tested using an iPhone 7.

That's a very sensible question, maybe some "enable high quality scan" could be created to enable decoding images without changing its source.

Is there any progress in this issue?
We have same problem in our project.
The package fail with the small 2DMatrix codes, but you can't go closer with the camera, because the minimal focus distance.
Perhaps a Zoom option would be help on that?

Now, on version v0.15.0 you can control the device's constraints. Also, I was wondering if maybe returning the media stream would be useful for advanced projects. Anyway, you can decode directly from you own requested media stream object. That said, now is possible to control anything - available in the browser - in the stream.

Decoding from custom constraints:

https://github.com/zxing-js/library/blob/2f6503eab60838998836e534524b158c58761e7d/src/browser/BrowserCodeReader.ts#L326-L340

Decoding from stream:

https://github.com/zxing-js/library/blob/2f6503eab60838998836e534524b158c58761e7d/src/browser/BrowserCodeReader.ts#L342-L358

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lenny76 picture lenny76  路  10Comments

mattmahn picture mattmahn  路  7Comments

mc-suchecki picture mc-suchecki  路  4Comments

kenlyon picture kenlyon  路  6Comments

majestic84 picture majestic84  路  8Comments