Barcode BarCodeReader DecodeType.DataMatrix

I’m having trouble scanning images and reading barcodes DataMatrix. and rarely read the code sometimes, how to solve the problem?

My Code
BarCodeReader reader = new BarCodeReader(bitmap, DecodeType.DataMatrix);
reader.QualitySettings = QualitySettings.HighQualityDetection;
reader.QualitySettings.AllowComplexBackground = true;
reader.QualitySettings.AllowDatamatrixIndustrialBarcodes = true;
reader.QualitySettings.AllowWhiteSpotsRemoving = true;
reader.QualitySettings.FastScanOnly = true;
reader.QualitySettings.AllowDecreasedImage = true;
reader.QualitySettings.AllowDetectScanGap = true;
reader.QualitySettings.AllowSaltAndPaperFiltering = true;
reader.QualitySettings.UseOldBarcodeDetector = true;
Console.WriteLine(reader.ReadBarCodes());
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine("Code Text: " + result.CodeText + " Symbology: " + result.CodeType);
string[] array = result.CodeText.Split(’-’);
}
}

Thank you

@menphurk,

Could you please zip and attach your barcode (image) file, we will check it soon.

WIAScannerLotto.zip (9.6 MB)
scaneb43resa.umi.jpg (177.8 KB)

@Amjad_Sahi :smiley:

@menphurk,

Thanks for the sample project and barcode image.

I did test using the following sample code and barcode image, it works ok.
e.g.
Sample code:

string bitmap1 = "e:\\test2\\barcode1\\scaneb43resa.umi.jpg";
            Aspose.BarCode.BarCodeRecognition.BarCodeReader reader12 = new Aspose.BarCode.BarCodeRecognition.BarCodeReader(bitmap1, Aspose.BarCode.BarCodeRecognition.DecodeType.AllSupportedTypes);
            reader12.QualitySettings = Aspose.BarCode.BarCodeRecognition.QualitySettings.HighQualityDetection;
            reader12.QualitySettings.AllowComplexBackground = true;
            reader12.QualitySettings.AllowDatamatrixIndustrialBarcodes = true;
            reader12.QualitySettings.AllowWhiteSpotsRemoving = true;
            reader12.QualitySettings.FastScanOnly = true;
            reader12.QualitySettings.AllowDecreasedImage = true;
            reader12.QualitySettings.AllowDetectScanGap = true;
            reader12.QualitySettings.AllowSaltAndPaperFiltering = true;
            reader12.QualitySettings.UseOldBarcodeDetector = true;
            Console.WriteLine("length is:" + reader12.ReadBarCodes().Length);
            foreach (Aspose.BarCode.BarCodeRecognition.BarCodeResult result in reader12.ReadBarCodes())
            {
            Console.WriteLine("Code Text: " + result.CodeText + " Symbology: " + result.CodeType);
            string[] array = result.CodeText.Split('-');
            } 

it reads two barcodes as following:

length is:2
Code Text: 64-01-31-373754-0672 Symbology: DataMatrix
Code Text: 2101317446209706 Symbology: Interleaved2of5

Do you see any issue with above results?

@Amjad_Sahi Image resolution: 399.9992 DPI
Image resolution: 399.9992 DPI
Image Width: 1855
Image Height: 900
Aspose.BarCode.BarCodeRecognition.BarCodeResult[]
length is:0

I test barcode length = 0

Read some barcode, some don’t.

1641843318619.jpg (101.6 KB)

I test again but image original. it read barcode found. Before not read barcode ??

1641843420180.jpg (98.7 KB)

The error suggests that it occurred in “System.Runtime.ComException” and not in Aspose.BarCode for .NET API.

I get code text and symbology for your provided picture “scaneb43resa.umi.jpg”.

In short, I could not reproduce the issue using my sample code, it also works ok when DecodeType.DataMatrix. To resolve your issue, we need to reproduce it, so could you create a separate sample code (runnable) with barcode image using only Aspose.BarCode API and provide us. We will check your issue soon.