-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathidentify-qr-code-structured-append-metadata-using-qrextendedparameters-for-multi-segment-qr-codes-in-images.cs
More file actions
63 lines (57 loc) · 2.71 KB
/
Copy pathidentify-qr-code-structured-append-metadata-using-qrextendedparameters-for-multi-segment-qr-codes-in-images.cs
File metadata and controls
63 lines (57 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Title: Identify QR Code Structured-Append Metadata
// Description: Demonstrates how to read QR code structured‑append information from an image using Aspose.BarCode.
// Prompt: Identify QR Code structured‑append metadata using QrExtendedParameters for multi‑segment QR codes in images.
// Tags: qr code, structured-append, barcode recognition, aspose.barcode, c#
using System;
using System.IO;
using Aspose.BarCode;
using Aspose.BarCode.BarCodeRecognition;
/// <summary>
/// Sample program that reads QR codes from an image and extracts structured‑append metadata
/// using the <c>QrExtendedParameters</c> provided by Aspose.BarCode.
/// </summary>
class Program
{
/// <summary>
/// Entry point of the application.
/// </summary>
static void Main()
{
// Path to the image containing multi‑segment QR codes.
const string imagePath = "qr_multi.png";
// Verify that the file exists before attempting to read it.
if (!File.Exists(imagePath))
{
Console.WriteLine($"File not found: {imagePath}");
return;
}
// Create a BarCodeReader configured to decode QR codes only.
using (var reader = new BarCodeReader(imagePath, DecodeType.QR))
{
// Iterate through all barcodes detected in the image.
foreach (BarCodeResult result in reader.ReadBarCodes())
{
// Output basic barcode information.
Console.WriteLine($"BarCode Type: {result.CodeTypeName}");
Console.WriteLine($"BarCode CodeText: {result.CodeText}");
// Access QR structured‑append metadata via the extended parameters.
var qrExt = result.Extended?.QR;
if (qrExt != null)
{
// Display the quantity of QR codes that belong to the same structured‑append group.
Console.WriteLine($"Structured Append Quantity: {qrExt.QRStructuredAppendModeBarCodesQuantity}");
// Display the index of the current QR code within the group (zero‑based).
Console.WriteLine($"Structured Append Index: {qrExt.QRStructuredAppendModeBarCodeIndex}");
// Display the parity data used for error detection across the group.
Console.WriteLine($"Structured Append Parity Data: {qrExt.QRStructuredAppendModeParityData}");
}
else
{
// No extended QR parameters were found for this barcode.
Console.WriteLine("No QR extended parameters available.");
}
Console.WriteLine(); // Separator between results.
}
}
}
}