如何从移动应用程序扫描 DPM 数据矩阵

How to scan a DPM datamatrix from a mobile app

我正在尝试利用 ZXing in an Android app to scan data matrixes. So far I'm successful with printed data matrixes such as this:

但其他激光打印或打孔的数据矩阵有 circle-looking 标记,而不是方形标记。

这些都存在问题。我发现唯一能够扫描的应用程序是 QRDroid. This article 说 QRDroid 使用 ZXing 所以我在想如果他们可以,一定有办法。不幸的是,QRDroid 不是一个开源项目,所以我不知道如何。

当然有可能 QRDroid 在尝试读取数据矩阵之前使用一种算法以某种方式将圆圈标记转换为方形标记。我对Java中的图像处理一无所知,所以我无法想象这是怎么做到的。

我的问题是是否有一种方法可以调整 ZXing 来读取这种类型的数据矩阵,或者是否有任何库可以用来操作图像以使其可被 ZXing 读取。

编辑:

如果我使用图像编辑器 - 例如我使用了 https://www.befunky.com- 并应用了 10 的模糊度,然后它看起来像一个普通的打印数据矩阵并且我的扫描工作正常。我应该如何在我的 Android 应用程序中执行此操作?

经过一些研究,我发现这种类型的标记实际上并不被视为标准数据矩阵,而是被制造业称为 DPM, which stands for "Direct Part Marking", although I've read other sources call it "Dot Peen Marking" or "Dot Peen Matrix"

我在一个已经存在的 issue in the Zxing 存储库上发布了同样的问题,这是我得到的回复:

The problem is the WhiteRectDetector. It finds a white rectangle inside the code, similar to this issue. If you rotate the image slightly (say 10°) or you blur it as you did or you did a suitably sized pixel dilation followed by an erosion, you'll get something that should (mostly) be detectable.

修改 WhiteRectDetector 以允许点而不是正方形对我来说并不是真正的选择,因为最后期限,所以我最终从 Zxing 切换到 Scandit, which is proven to be able to scan this

Scandit 是专有库,但我还没有真正找到任何其他替代品。不过,您可以获得试用许可证。对于那些想尝试扫描 DPM 的人来说,文档对如何启用此符号系统的扫描不是很清楚,所以这里是诀窍。

在Android中:

settings.getSymbologySettings(Barcode.SYMBOLOGY_DATA_MATRIX)
.setExtensionEnabled("direct_part_marking_mode", true);

在Objective-C中:

[[settings settingsForSymbology:SBSSymbologyDatamatrix] 
setExtension:@"direct_part_marking_mode" enabled:YES];