Aspose.BarCode を使用してマイクロ QR コードをスキャンする方法 .NET

Aspose.BarCode を使用してマイクロ QR コードをスキャンする方法 .NET

この記事では、どのように マイクロQRコードのスキャンと解読 マイクロQRコードは、標準QRへのより小さく、よりコンパクトな代替品であり、ラベル、チケット、またはインベンチャータグにスペース制限されたアプリケーションに最適です。.

現実世界問題

マイクロQRコードは、スペースがプレミアムにあった場合、製造、医療、電子、物流で使用されます。標準QR認証ライブラリは、これらの小さなコードを信頼性がありません。開発者は、マイクロQRを .NET アプリケーションで解読するための専門的で正確な方法が必要です。.

解決策概要

Aspose.BarCode for .NET fully supports Micro QR code detection and recognition. You simply configure the reader for DecodeType.MicroQR,API は、これらのコンパクトシンボルをサポートされている画像またはストリームで処理します。.


原則

始める前に、あなたが持っていることを確認してください:

  1. Visual Studio 2019 またはその後の
  2. .NET 6.0 またはそれ以降(または .NET Framework 4.6.2+)
  3. Aspose.BarCode for .NET installed via NuGet
  4. C#の基本知識
PM> Install-Package Aspose.BarCode

ステップ・ステップ・実施

ステップ1:インストールして設定する Aspose.BarCode

Aspose.BarCode パッケージを追加し、必要な名称スペースを含む:

using Aspose.BarCode.BarCodeRecognition;

ステップ2:入力データの準備

マイクロQRコード(たとえば「micro_qr_sample.png」)を含む画像ファイルを取得します。.

string imagePath = "micro_qr_sample.png";

ステップ3:マイクロQR認証オプションを設定する

読者を設定して、Micro QR コードを具体的に検索する:

BarCodeReader reader = new BarCodeReader(imagePath, DecodeType.MicroQR);

ステップ4:マイクロQRスキャンプロセスを実行

foreach (BarCodeResult result in reader.ReadBarCodes())
{
    Console.WriteLine($"Type: {result.CodeTypeName}");
    Console.WriteLine($"Text: {result.CodeText}");
}

ステップ5:出力と認証の処理

必要に応じて、解読されたマイクロQRデータを使用する(例えば、製品ID、ロット番号、トラッキングコード)。.


ステップ6:エラー処理の実施

using Aspose.BarCode.BarCodeRecognition;
using System;

class Program
{
    static void Main()
    {
        string imagePath = "micro_qr_sample.png";
        try
        {
            using (BarCodeReader reader = new BarCodeReader(imagePath, DecodeType.MicroQR))
            {
                foreach (BarCodeResult result in reader.ReadBarCodes())
                {
                    Console.WriteLine($"Type: {result.CodeTypeName}");
                    Console.WriteLine($"Text: {result.CodeText}");
                }
        }
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error: {ex.Message}");
        }
    }
} 

完全例

using Aspose.BarCode.BarCodeRecognition;
using System;

class Program
{
    static void Main()
    {
        string imagePath = "micro_qr_sample.png";
        try
        {
            using (BarCodeReader reader = new BarCodeReader(imagePath, DecodeType.MicroQR))
            {
                foreach (BarCodeResult result in reader.ReadBarCodes())
                {
                    Console.WriteLine($"Type: {result.CodeTypeName}");
                    Console.WriteLine($"Text: {result.CodeText}");
                }
        }
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error: {ex.Message}");
        }
    }
} 

ケースとアプリケーションの使用

  • 小さなラベル: 電子、宝石、薬品における資産追跡
  • 製造: サークルボードまたはコンポーネントのマーク
  • イベントチケット: アクセスコントロールのための超コンパクトコード

共通の課題と解決策

課題1:マイクロQRが検出されていない 解決策: 画像が明るく、十分な解像度と適切な照明を保証します。.

課題2:多種多様なバーコードの種類 解決策: セット DecodeType.MicroQR スキャンをマイクロQRに制限する。.

課題3:出力テキストは読み取れない 解決策: コードが物理的に損傷されていないか、スキャンするにはあまりにも小さく印刷されていないかを確認してください。.


パフォーマンス考慮

  • 最高の結果を得るために、清潔で高解像度の画像を使用する
  • 読者を利用して資源をリリース
  • 複数のファイルをスキャンすると、可能な限りメモリで処理します。

最良の実践

  1. 異なるマイクロQRバージョンと印刷品質でテストスキャン
  2. 認証をマイクロQRに厳密に制限する場合、これらのコードのみが存在する場合
  3. すべてのデータを記録して監査と追跡性
  4. 信頼性のための適切なエラー処理を使用する

進歩的なシナリオ

1. Batch Scan Micro QR from a Stream

using Aspose.BarCode.BarCodeRecognition;
byte[] imageBytes = File.ReadAllBytes("qr_sample.png");
using (MemoryStream ms = new MemoryStream(imageBytes))
using (BarCodeReader reader = new BarCodeReader(ms, DecodeType.QR))
{
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        Console.WriteLine(result.CodeText);
    }
}

2. Validate Product IDs from Micro QR

using Aspose.BarCode.BarCodeRecognition;
using System.Collections.Generic;

List<string> productIds = new List<string>();
string imagePath = "sample.png"; // Use a valid test file path

using (BarCodeReader reader = new BarCodeReader(imagePath, DecodeType.MicroQR))
{
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        productIds.Add(result.CodeText);
    }
}
// Validate or process productIds as required

結論

Aspose.BarCode for .NET を使用すると、どの .NET ワークフローでも、スペース制限されたアプリケーションのための強力でコンパクトなコードサポートを確保するために、Micro QR コードを信頼性的にスキャンできます。.

詳細については、Aspose.BarCode を参照してください。 火の参考 .

 日本語