Aspose.BarCode を使用して 直角のマイクロ QR コードをスキャンする方法 .NET
この記事では、どのように スキャン・デコード 直角マイクロQRコード(rMQR) レクトンガーラーマイクロQRは、スペース制限のラベル、電子、文書制御に最適な、直角形のQRバージョンです。.
現実世界問題
バーコードが限られた高さまたは限られた幅のスペースに合う必要がある場合 - ケーブル、印刷板、チケットなど - 標準QRまたはマイクロQR形式は理想的ではありません。.
解決策概要
Aspose.BarCode for .NET fully supports detection and recognition of rMQR codes. Simply configure the reader for DecodeType.RMQR,API は、サポートされている画像またはストリームから直角のマイクロ QR コードを処理します。.
原則
始める前に、あなたが持っていることを確認してください:
- Visual Studio 2019 またはその後の
- .NET 6.0 またはそれ以降(または .NET Framework 4.6.2+)
- Aspose.BarCode for .NET installed via NuGet
- C#の基本知識
PM> Install-Package Aspose.BarCodeステップ・ステップ・実施
ステップ1:インストールして設定する Aspose.BarCode
Aspose.BarCode パッケージを追加し、必要な名称スペースを含む:
using Aspose.BarCode.BarCodeRecognition;ステップ2:入力データの準備
画像ファイルを取得し、Rectangular Micro QR コード(例えば「rmqr_sample.png」)を含む。.
string imagePath = "rmqr_sample.png";ステップ3: rMQR 認定オプションを設定する
読者を設定して、Rectangular Micro QR コードを具体的に検索する:
BarCodeReader reader = new BarCodeReader(imagePath, DecodeType.RMQR);ステップ4: rMQR スキャンプロセスを実行
foreach (BarCodeResult result in reader.ReadBarCodes())
{
Console.WriteLine($"Type: {result.CodeTypeName}");
Console.WriteLine($"Text: {result.CodeText}");
}ステップ5:出力と認証の処理
必要に応じて、解読された rMQR データを使用する(例えば、部品番号、製造コード、物流データ)。.
ステップ6:エラー処理の実施
using Aspose.BarCode.BarCodeRecognition;
using System;
class Program
{
static void Main()
{
string imagePath = "QR_sample.png";
try
{
using (BarCodeReader reader = new BarCodeReader(imagePath, DecodeType.QR))
{
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;
class Program
{
public static void Main(string[] args)
{
string imagePath = "path_to_your_image.png"; // Add this line to declare the variable
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}");
}
}
}ケースとアプリケーションの使用
- スペース限定ラベル: 電子、PCB製造、ケーブルタグ
- セキュア・ドキュメント・トラッキング: 限定マージンまたは小型形式のユニークID
- イベントチケット: スピードスキャンのためのコンパクト正角コード
共通の課題と解決策
課題1: rMQR 未発見 解決策: 画像の質がコードのサイズに十分に高く保証し、適切な照明を使用します。.
課題2:他のバーコードタイプが存在する 解決策: 使用する rMQR に制限するスキャン DecodeType.RMQR.
課題3:デコードされたテキストは、不完全または不完全です。 解決策: バーコードに物理的な損傷を確認し、あまり小さく印刷されないようにしてください。.
パフォーマンス考慮
- 明るく、高解像度の画像を使用する
- 使用後、読者インスタンスを提供
- スキャンスケールでスキャンした場合の記憶にバッチ画像を処理
最良の実践
- 他のタイプが存在する場合、rMQRに解読を制限する
- 異なる rMQR バージョンとレイアウトでテストスキャン
- すべての出力を記録して監査と追跡性
- すべての生産コードで構造化された例外処理を使用する
進歩的なシナリオ
1. Batch Scan rMQR 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. Collect rMQR Data for Manufacturing Workflow
using Aspose.BarCode.BarCodeRecognition;
using System;
class Program
{
static void Main()
{
string imagePath = "multiple_barcodes.png"; // Replace with your file
using (BarCodeReader reader = new BarCodeReader(imagePath, DecodeType.UPCA, DecodeType.EAN13, DecodeType.Code39, DecodeType.Code128))
{
foreach (BarCodeResult result in reader.ReadBarCodes())
Console.WriteLine($"Type: {result.CodeTypeName}, Value: {result.CodeText}");
}
}
} 結論
Aspose.BarCode for .NET lets you reliably scan rectangular micro QR codes, enabling compact, efficient labeling and secure data management for space-limited applications.
詳細については、Aspose.BarCode を参照してください。 火の参考 .