在.NET中识别具有空间扭曲的二维矩阵条形码

博客分类:条形码   .NET

2020/05/06

VintaSoft Barcode .NET SDK 可用于 .NET/C# 应用程序,识别具有随机表面变形的二维 Aztec、QR 码和汉信码条形码。实际上,这大大简化了使用相机、网络摄像头或智能手机摄像头识别条形码的过程,因为现在无需将条形码对准摄像头,甚至可以识别不平整表面上的条形码。

First sample of Aztec barcode with spatial distortions


我们的开发人员花费了大量时间,利用网络摄像头和照相机开发并改进了扭曲校正算法。您可以在下方通过我们的条形码阅读器的"眼睛"观察这些条形码:

View to the Aztec barcode with spatial distortions via 'eyes' of barcode reader of VintaSoft Barcode .NET SDK

我们的开发人员最终能够准确地看到这些条形码。:)


以下是能够识别具有空间扭曲的阿兹特克条形码、"QR Code"和"韩信码"的C#代码:
/// <summary>
/// Recognizes 2D matrix barcodes (Aztec, QR Code and Han Xin Code) with spatial distortions.
/// </summary>
public void Recognize2dBarcodeWithSpatialDistortions()
{
    // create barcode reader
    using (Vintasoft.Barcode.BarcodeReader reader = new Vintasoft.Barcode.BarcodeReader())
    {
        // specify that reader must search for Aztec, QR and Han Xin Code barcodes
        reader.Settings.ScanBarcodeTypes = Vintasoft.Barcode.BarcodeType.Aztec |
            Vintasoft.Barcode.BarcodeType.QR |
            Vintasoft.Barcode.BarcodeType.HanXinCode;

        // specify that reader must search for horizontal and vertical barcodes only
        reader.Settings.ScanDirection = Vintasoft.Barcode.ScanDirection.Horizontal | Vintasoft.Barcode.ScanDirection.Vertical;

        // read barcodes from image file
        Vintasoft.Barcode.IBarcodeInfo[] barcodeInfos = reader.ReadBarcodes("barcodes.png");

        // if barcodes are not detected
        if (barcodeInfos.Length == 0)
        {
            System.Console.WriteLine("Barcodes are not found.");
        }
        // if barcodes are detected
        else
        {
            // get information about recognized barcodes

            System.Console.WriteLine(string.Format("{0} barcode(s) found:", barcodeInfos.Length));
            System.Console.WriteLine();
            for (int i = 0; i &lt; barcodeInfos.Length; i++)
            {
                Vintasoft.Barcode.IBarcodeInfo barcodeInfo = barcodeInfos[i];
                System.Console.WriteLine(string.Format("[{0}:{1}]", i + 1, barcodeInfo.BarcodeType));
                System.Console.WriteLine(string.Format("Value:      {0}", barcodeInfo.Value));
                System.Console.WriteLine(string.Format("Region:     {0}", barcodeInfo.Region));
                System.Console.WriteLine();
            }
        }
    }
}


测试表明,条形码读取器可以成功处理以下一种或多种类型的失真:

以下是一些带有失真条形码的图像:
Second sample of Aztec barcode with spatial distortions

Third sample of Aztec barcode with spatial distortions

First sample of Han Xin Code barcode with spatial distortions

Second sample of Han Xin Code barcode with spatial distortions

First sample of QR barcode with spatial distortions

Second sample of QR barcode with spatial distortions


您可以在VintaSoft Barcode .NET SDK的发行包中找到更多条形码变形的图片。

如果您在条形码识别方面遇到任何问题,并且认为我们的条形码识别算法可以解决这些问题,请将您的图片发送至support@vintasoft.com进行测试和审核。