AdditionalGrades Property (ISO15415QualityTest)
In This Topic
Gets the additional grades that depends from barcode symbology.
Syntax
Remarks
Additional grades for Data Matrix barcode (defined in ISO 16022 Annex M):
- FixedPatternDamage.L1 - Grade of segment L1 (see below).
- FixedPatternDamage.L2 - Grade of segment L2 (see below).
- FixedPatternDamage.QZL1 - Grade of segment QZL1 (see below).
- FixedPatternDamage.QZL2 - Grade of segment QZL2 (see below).
- FixedPatternDamage.Segment_X_Y_Top - Grade of top alignment patterns (clock track and solid area) of data region located by specified indexes (X, Y).
- FixedPatternDamage.Segment_X_Y_Right - Grade of right alignment patterns (clock track and solid area) of data region located by specified indexes (X, Y).
- FixedPatternDamage.ClockAndSolidArea - Grade of all alignment patterns of data regions.
- FixedPatternDamage.AG - Grade of average grade of L1, L2, QZL1, QZL2, ClockAndSolidArea.
Segment L1 is the vertical portion of the L and extends to the module in the quiet zone adjacent to the L corner. Segment L2 is the horizontal portion of the L and extends to the module in the quiet zone adjacent to the L corner. Segments QZL1 and QZL2 are the portions of the quiet zone adjacent to L1 and L2 respectively and extend one module beyond the end of L1 and L2 respectively, furthest from the corner.
Additional grades for Han Xin Code Matrix barcode (defined in specification):
- FixedPatternDamage.A1 - Grade of 11x11 in symbol left top corner (finder pattern and quiet zone).
- FixedPatternDamage.A2 - Grade of 11x11 in symbol right top corner (finder pattern and quiet zone).
- FixedPatternDamage.A3 - Grade of 11x11 in symbol right bottom corner (finder pattern and quiet zone).
- FixedPatternDamage.A4 - Grade of 11x11 in symbol left bottom corner (finder pattern and quiet zone).
- FixedPatternDamage.B - Grade of Alignment Pattern and Assistant Alignment Pattern.
- StructuralInformationRegion.Region1 - Grade of Structural Information Region 1 (left top and right top).
- StructuralInformationRegion.Region2 - Grade of Structural Information Region 1 (left bottom and right bottom).
- StructuralInformationRegion.Region - Grade of Structural Information Region 1 and Region 2.
Example
Here is an example that demonstrates how to test print quality of matrix 2D barcodes (Aztec, DataMatrix, QR and MicroQR):
Imports Vintasoft.Imaging
Imports Vintasoft.Barcode
Imports Vintasoft.Barcode.BarcodeInfo
Imports Vintasoft.Barcode.QualityTests
''' <summary>
''' Test that shows how to test the print quality of matrix 2D barcodes
''' (Aztec, DataMatrix, Han Xin Code, QR and MicroQR).
''' </summary>
Class ISO15415QualityTestMatrixExample
''' <summary>
''' Runs the test.
''' </summary>
Public Shared Sub Test()
' load image with barcode from file
Using barcodeImage As VintasoftBitmap = ImageCodecs.[Default].Decode("test1.jpg")
' read barcodes from image and test the print quality of 2D barcodes
ReadBarcodesAndTestBarcodePrintQuality(barcodeImage)
End Using
End Sub
''' <summary>
''' Reads barcodes from image and tests the print quality of 2D barcodes.
''' </summary>
Public Shared Sub ReadBarcodesAndTestBarcodePrintQuality(imageWithBarcodes As VintasoftBitmap)
' create the barcode reader
Using reader As New BarcodeReader()
' specify that reader must collect information for quality test
reader.Settings.CollectTestInformation = True
' specify that reader must search for Aztec, DataMatrix, Han Xin Code, QR and MicroQR barcodes only
reader.Settings.ScanBarcodeTypes = BarcodeType.Aztec Or BarcodeType.DataMatrix Or BarcodeType.QR Or BarcodeType.MicroQR Or BarcodeType.HanXinCode
' read barcodes
Dim barcodeInfos As IBarcodeInfo() = reader.ReadBarcodes(imageWithBarcodes)
' for each found barcode
For i As Integer = 0 To barcodeInfos.Length - 1
' test print quality of barcode using ISO 15415 test
Dim test As New ISO15415QualityTest()
test.CalculateGrades(DirectCast(barcodeInfos(i), BarcodeInfo2D), imageWithBarcodes)
' print results of ISO 15415 test
Console.WriteLine(String.Format("[{0}] {1}", barcodeInfos(i).BarcodeType, barcodeInfos(i).Value))
Console.WriteLine(String.Format("Decode : {0}", GradeToString(test.DecodeGrade)))
Console.WriteLine(String.Format("Unused error correction : {0} ({1}%)", GradeToString(test.UnusedErrorCorrectionGrade), test.UnusedErrorCorrection))
Console.WriteLine(String.Format("Symbol contrast : {0} ({1}%)", GradeToString(test.SymbolContrastGrade), test.SymbolContrast))
Console.WriteLine(String.Format("Axial nonuniformity : {0} ({1})", GradeToString(test.AxialNonuniformityGrade), test.AxialNonuniformity))
Console.WriteLine(String.Format("Grid nonuniformity : {0} ({1} cell)", GradeToString(test.GridNonuniformityGrade), test.GridNonuniformity))
Console.WriteLine(String.Format("Modulation : {0}", GradeToString(test.ModulationGrade)))
Console.WriteLine(String.Format("Reflectance margin : {0}", GradeToString(test.ReflectanceMarginGrade)))
Console.WriteLine(String.Format("Fixed pattern damage : {0}", GradeToString(test.FixedPatternDamageGrade)))
For Each name As String In test.AdditionalGrades.Keys
Console.WriteLine(String.Format("{0}: {1}", name.PadRight(40, " "C), GradeToString(test.AdditionalGrades(name))))
Next
If test.QuietZone >= 0 Then
Console.WriteLine(String.Format("Quiet zone : {0} ({1} %)", GradeToString(test.QuietZoneGrade), test.QuietZone))
End If
Console.WriteLine(String.Format("Distortion angle (informative) : {0}�", test.DistortionAngle))
Console.WriteLine(String.Format("-------------Scan grade : {0}", GradeToString(test.ScanGrade)))
Console.WriteLine()
Next
End Using
End Sub
''' <summary>
''' Converts ISO15415 quality grade into string value.
''' </summary>
Private Shared Function GradeToString(grade As ISO15415QualityGrade) As String
Return String.Format("{0}({1})", CInt(grade).ToString(), grade)
End Function
End Class
using System;
using Vintasoft.Imaging;
using Vintasoft.Barcode;
using Vintasoft.Barcode.BarcodeInfo;
using Vintasoft.Barcode.QualityTests;
/// <summary>
/// Test that shows how to test the print quality of matrix 2D barcodes
/// (Aztec, DataMatrix, Han Xin Code, QR and MicroQR).
/// </summary>
class ISO15415QualityTestMatrixExample
{
/// <summary>
/// Runs the test.
/// </summary>
public static void Test()
{
// load image with barcode from file
using (VintasoftBitmap barcodeImage = ImageCodecs.Default.Decode("test1.jpg"))
{
// read barcodes from image and test the print quality of 2D barcodes
ReadBarcodesAndTestBarcodePrintQuality(barcodeImage);
}
}
/// <summary>
/// Reads barcodes from image and tests the print quality of 2D barcodes.
/// </summary>
public static void ReadBarcodesAndTestBarcodePrintQuality(VintasoftBitmap imageWithBarcodes)
{
// create the barcode reader
using (BarcodeReader reader = new BarcodeReader())
{
// specify that reader must collect information for quality test
reader.Settings.CollectTestInformation = true;
// specify that reader must search for Aztec, DataMatrix, Han Xin Code, QR and MicroQR barcodes only
reader.Settings.ScanBarcodeTypes =
BarcodeType.Aztec | BarcodeType.DataMatrix |
BarcodeType.QR | BarcodeType.MicroQR | BarcodeType.HanXinCode;
// read barcodes
IBarcodeInfo[] barcodeInfos = reader.ReadBarcodes(imageWithBarcodes);
// for each found barcode
for (int i = 0; i < barcodeInfos.Length; i++)
{
// test print quality of barcode using ISO 15415 test
ISO15415QualityTest test = new ISO15415QualityTest();
test.CalculateGrades((BarcodeInfo2D)barcodeInfos[i], imageWithBarcodes);
// print results of ISO 15415 test
Console.WriteLine(string.Format("[{0}] {1}",
barcodeInfos[i].BarcodeType, barcodeInfos[i].Value));
Console.WriteLine(string.Format("Decode : {0}",
GradeToString(test.DecodeGrade)));
Console.WriteLine(string.Format("Unused error correction : {0} ({1}%)",
GradeToString(test.UnusedErrorCorrectionGrade), test.UnusedErrorCorrection));
Console.WriteLine(string.Format("Symbol contrast : {0} ({1}%)",
GradeToString(test.SymbolContrastGrade), test.SymbolContrast));
Console.WriteLine(string.Format("Axial nonuniformity : {0} ({1})",
GradeToString(test.AxialNonuniformityGrade), test.AxialNonuniformity));
Console.WriteLine(string.Format("Grid nonuniformity : {0} ({1} cell)",
GradeToString(test.GridNonuniformityGrade), test.GridNonuniformity));
Console.WriteLine(string.Format("Modulation : {0}",
GradeToString(test.ModulationGrade)));
Console.WriteLine(string.Format("Reflectance margin : {0}",
GradeToString(test.ReflectanceMarginGrade)));
Console.WriteLine(string.Format("Fixed pattern damage : {0}",
GradeToString(test.FixedPatternDamageGrade)));
foreach (string name in test.AdditionalGrades.Keys)
Console.WriteLine(string.Format("{0}: {1}",
name.PadRight(40, ' '), GradeToString(test.AdditionalGrades[name])));
if (test.QuietZone >= 0)
Console.WriteLine(string.Format("Quiet zone : {0} ({1} %)",
GradeToString(test.QuietZoneGrade), test.QuietZone));
Console.WriteLine(string.Format("Distortion angle (informative) : {0}°",
test.DistortionAngle));
Console.WriteLine(string.Format("-------------Scan grade : {0}",
GradeToString(test.ScanGrade)));
Console.WriteLine();
}
}
}
/// <summary>
/// Converts ISO15415 quality grade into string value.
/// </summary>
static string GradeToString(ISO15415QualityGrade grade)
{
return string.Format("{0}({1})", ((int)grade).ToString(), grade);
}
}
Requirements
Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
See Also