6

我的目标是在这样的更大图像(四个大图像)上检测多个数据矩阵:

全图

根据几个代码示例,我做了一个小测试程序:

Bitmap image = getImage();

DataMatrixReader reader = new DataMatrixReader();
GenericMultipleBarcodeReader genericReader = new genericMultipleBarcodeReader(reader);
Dictionary<DecodeHintType, object> hints = new Dictionary<DecodeHintType,object>();
hints.Add(DecodeHintType.TRY_HARDER, true);

BitmapLuminanceSource source = new BitmapLuminanceSource(image);
HybridBinarizer binarizer = new HybridBinarizer(source);
BinaryBitmap binaryBitmap = new BinaryBitmap(binarizer);
Result[] results = genericReader.decodeMultiple(binaryBitmap,hints);

show(results);

它无法检测到大图像上的任何代码。

但它可以检测到代码,当它像这样裁剪时:

裁剪

之后我合并了两个生成的数据矩阵,它也失败了:

在此处输入图像描述

最后,我用略微裁剪的图像再进行了两次测试,都失败了:

在此处输入图像描述

在此处输入图像描述

所以看起来这个库根本不健壮,或者我用错了。

知道如何改善我的结果吗?(包括其他库和预处理)

4

1 回答 1

3

It can't be said that the library is not robust but there are two key factors affecting you here:

  • Zxing's data-matrix detection algorithm assumes that the barcode is centered. Or more precisely, that the center of the image is inside the data-matrix.
  • Zxing's multiple reader specially fails when barcodes are grid-aligned.

My recommendation is to implement your own MultipleBarcodeReader taking into account what I've mentioned.

A naive approach could be to take sample images centered over a grid of points spaced so every data-matrix (no matter its position within the image) contain at least one of the points inside. You just have to make sure to exclude duplicated codes.

于 2015-01-30T07:05:46.817 回答