My aim is to detect multiple datamatrices on a larger image like this (the four big):
Based on several code samples, I made a small test program:
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);
It could'nt detect any code on the large image.
But it can detect the code, when its cropped like that:
After that I merged two generated data matrices, and it failed too:
Last I ran two more test with slightly cropped images, both failed:
So it seems this library is not robust at all, or maybe I use it wrong.
Any idea how to improve my results? (including other libraries and preprocessing)
It can't be said that the library is not robust but there are two key factors affecting you here:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With