.NET で空間歪みのある 2D マトリックス バーコードを認識

ブログ カテゴリ: バーコード.NET

2020/05/06

VintaSoft Barcode .NET SDK は、.NET/C# アプリケーションで、ランダムな表面歪みのある 2 次元 Aztec、QR コード、Han Xin コードのバーコードを認識するために使用できます。実際には、これにより、写真カメラ、web カメラ、またはスマートフォン カメラからのバーコード認識が大幅に簡素化されます。バーコードをカメラの前に合わせる必要がなくなり、凹凸のある表面からバーコードを認識できるようになるためです。




当社の開発者は、ウェブカメラと写真カメラを用いた歪み補正アルゴリズムの開発と改良に多くの時間を費やしてきました。以下は、当社のバーコードリーダーの「目」を通して、このようなバーコードを見ることができるものです。



ある瞬間、当社の開発者はまさにこのようなバーコードを見るようになりました。:)


以下は、Aztecを認識するC#コードです。空間的な歪みがある QR コードと Han Xin Code バーコード:
/// <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();
            }
        }
    }
}


テストの結果、バーコード リーダーは以下に指定する 1 つ以上の種類の歪みを正常に処理できることが示されました:

歪んだバーコードのある画像をいくつか示します:













歪んだバーコードのあるその他の画像は、VintaSoft Barcode .NET SDK の配布パッケージ内にあります。

バーコード認識で問題が発生し、当社のバーコード認識アルゴリズムで解決できると思われる場合は、テストとレビューのために support@vintasoft.com まで画像をお送りください。