How to Scan Rectangular Micro QR Codes Using Aspose.BarCode for .NET

How to Scan Rectangular Micro QR Codes Using Aspose.BarCode for .NET

This article explains how to scan and decode Rectangular Micro QR codes (rMQR) using Aspose.BarCode for .NET. Rectangular Micro QR is a compact QR variant with a rectangular shape, perfect for space-constrained labeling, electronics, and document control.

Real-World Problem

When barcodes must fit into limited-height or limited-width spaces—such as on cables, printed boards, or tickets—standard QR or Micro QR formats are not ideal. Developers need a way to read rectangular QR symbols reliably, even if they are tightly packed or small.

Solution Overview

Aspose.BarCode for .NET fully supports detection and recognition of rMQR codes. Simply configure the reader for DecodeType.RMQR, and the API will process rectangular micro QR codes from any supported image or stream.


Prerequisites

Before you start, ensure you have:

  1. Visual Studio 2019 or later
  2. .NET 6.0 or later (or .NET Framework 4.6.2+)
  3. Aspose.BarCode for .NET installed via NuGet
  4. Basic knowledge of C#
PM> Install-Package Aspose.BarCode

Step-by-Step Implementation

Step 1: Install and Configure Aspose.BarCode

Add the Aspose.BarCode package and include the required namespace:

using Aspose.BarCode.BarCodeRecognition;

Step 2: Prepare Your Input Data

Obtain an image file containing a Rectangular Micro QR code (e.g., “rmqr_sample.png”).

string imagePath = "rmqr_sample.png";

Step 3: Configure rMQR Recognition Options

Set the reader to look specifically for Rectangular Micro QR codes:

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

Step 4: Execute the rMQR Scanning Process

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

Step 5: Handle Output and Validation

Use the decoded rMQR data as needed (e.g., part numbers, manufacturing codes, logistics data).


Step 6: Implement Error Handling

try
{
    using (BarCodeReader reader = new BarCodeReader(imagePath, DecodeType.RMQR))
    {
        foreach (BarCodeResult result in reader.ReadBarCodes())
        {
            Console.WriteLine($"Type: {result.CodeTypeName}");
            Console.WriteLine($"Text: {result.CodeText}");
        }
    }
}
catch (Exception ex)
{
    Console.WriteLine($"Error: {ex.Message}");
}

Complete Example

using Aspose.BarCode.BarCodeRecognition;
using System;

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

Use Cases and Applications

  • Space-constrained Labeling: Electronics, PCB manufacturing, cable tagging
  • Secure Document Tracking: Unique IDs in limited margins or small forms
  • Event Ticketing: Compact rectangular code for rapid scanning

Common Challenges and Solutions

Challenge 1: rMQR not detected Solution: Ensure image quality is high enough for the code’s size; use proper lighting.

Challenge 2: Other barcode types present Solution: Restrict scanning to rMQR using DecodeType.RMQR.

Challenge 3: Decoded text is garbled or incomplete Solution: Check for physical damage to the barcode and make sure it is not printed too small.


Performance Considerations

  • Use clear, high-resolution images
  • Dispose of reader instances after use
  • Batch process images in memory if scanning at scale

Best Practices

  1. Restrict decoding to rMQR if other types are present
  2. Test scanning with different rMQR versions and layouts
  3. Log all output for auditing and traceability
  4. Use structured exception handling in all production code

Advanced Scenarios

1. Batch Scan rMQR from a Stream

using (FileStream fs = File.OpenRead(imagePath))
using (BarCodeReader reader = new BarCodeReader(fs, DecodeType.RMQR))
{
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        Console.WriteLine(result.CodeText);
    }
}

2. Collect rMQR Data for Manufacturing Workflow

List<string> partNumbers = new List<string>();
using (BarCodeReader reader = new BarCodeReader(imagePath, DecodeType.RMQR))
{
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        partNumbers.Add(result.CodeText);
    }
}
// Process partNumbers as needed

Conclusion

Aspose.BarCode for .NET lets you reliably scan rectangular micro QR codes, enabling compact, efficient labeling and secure data management for space-limited applications.

For further details, see the Aspose.BarCode API Reference .

 English