ISO15416QualityTest Class
In This Topic
ISO/IEC 15416 barcode print quality test for 1D linear barcodes.
Object Model
Syntax
'Declaration
Public Class ISO15416QualityTest
public class ISO15416QualityTest
public __gc class ISO15416QualityTest
public ref class ISO15416QualityTest
Remarks
The algorithm of test is based on ISO/IEC 15416. Test allows to evaluate the barcode's print quality using the following parameters:
Example
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 1D barcodes.
''' </summary>
Class ISO15416QualityTestExample
''' <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 1D barcodes
ReadBarcodesAndTestBarcodePrintQuality(barcodeImage)
End Using
End Sub
''' <summary>
''' Reads barcodes from image and tests the print quality of 1D barcodes.
''' </summary>
Private 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 Code39 and Code128 barcodes only
reader.Settings.ScanBarcodeTypes = BarcodeType.Code39 Or BarcodeType.Code128
' 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 15416 test
Dim test As New ISO15416QualityTest(DirectCast(barcodeInfos(i), BarcodeInfo1D), imageWithBarcodes)
' print results of ISO 15416 test
Console.WriteLine(String.Format("[{0}] {1}", barcodeInfos(i).BarcodeType, barcodeInfos(i).Value))
Console.WriteLine(String.Format("Overall symbol grade: {0} ({1:f2})", test.OverallSymbolGrade, test.OverallSymbolGradeValue))
If test.DifferentDecodedValues Then
Console.WriteLine("Scan profiles has different barcode decode values!")
End If
If test.SymbolComponentQualityTests.Length = 1 Then
Dim qualityTest As ISO15416SymbolComponentQualityTest = test.SymbolComponentQualityTests(0)
Console.WriteLine(String.Format("Scan reflectance profiles: {0}", qualityTest.ScanReflectanceProfiles.Length))
Console.WriteLine("Scan reflectance profile grades:")
For j As Integer = 0 To qualityTest.ScanReflectanceProfiles.Length - 1
Console.Write(qualityTest.ScanReflectanceProfiles(j).ScanGrade)
Next
Else
For k As Integer = 0 To test.SymbolComponentQualityTests.Length - 1
Console.WriteLine(String.Format("Symbol component: {0}", k + 1))
Dim qualityTest As ISO15416SymbolComponentQualityTest = test.SymbolComponentQualityTests(k)
Console.WriteLine(String.Format("Scan reflectance profiles: {0}", qualityTest.ScanReflectanceProfiles.Length))
Console.WriteLine("Scan reflectance profile grades:")
For j As Integer = 0 To qualityTest.ScanReflectanceProfiles.Length - 1
Console.Write(qualityTest.ScanReflectanceProfiles(j).ScanGrade)
Next
Next
End If
Console.WriteLine()
Console.WriteLine()
Next
End Using
End Sub
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 1D barcodes.
/// </summary>
class ISO15416QualityTestExample
{
/// <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 1D barcodes
ReadBarcodesAndTestBarcodePrintQuality(barcodeImage);
}
}
/// <summary>
/// Reads barcodes from image and tests the print quality of 1D barcodes.
/// </summary>
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 Code39 and Code128 barcodes only
reader.Settings.ScanBarcodeTypes = BarcodeType.Code39 | BarcodeType.Code128;
// 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 15416 test
ISO15416QualityTest test =
new ISO15416QualityTest((BarcodeInfo1D)barcodeInfos[i], imageWithBarcodes);
// print results of ISO 15416 test
Console.WriteLine(string.Format("[{0}] {1}",
barcodeInfos[i].BarcodeType, barcodeInfos[i].Value));
Console.WriteLine(string.Format("Overall symbol grade: {0} ({1:f2})",
test.OverallSymbolGrade, test.OverallSymbolGradeValue));
if (test.DifferentDecodedValues)
Console.WriteLine("Scan profiles has different barcode decode values!");
if (test.SymbolComponentQualityTests.Length == 1)
{
ISO15416SymbolComponentQualityTest qualityTest = test.SymbolComponentQualityTests[0];
Console.WriteLine(string.Format("Scan reflectance profiles: {0}",
qualityTest.ScanReflectanceProfiles.Length));
Console.WriteLine("Scan reflectance profile grades:");
for (int j = 0; j < qualityTest.ScanReflectanceProfiles.Length; j++)
Console.Write(qualityTest.ScanReflectanceProfiles[j].ScanGrade);
}
else
{
for (int k = 0; k < test.SymbolComponentQualityTests.Length; k++)
{
Console.WriteLine(string.Format("Symbol component: {0}", k + 1));
ISO15416SymbolComponentQualityTest qualityTest = test.SymbolComponentQualityTests[k];
Console.WriteLine(string.Format("Scan reflectance profiles: {0}",
qualityTest.ScanReflectanceProfiles.Length));
Console.WriteLine("Scan reflectance profile grades:");
for (int j = 0; j < qualityTest.ScanReflectanceProfiles.Length; j++)
Console.Write(qualityTest.ScanReflectanceProfiles[j].ScanGrade);
}
}
Console.WriteLine();
Console.WriteLine();
}
}
}
}
Inheritance Hierarchy
System.Object
 Vintasoft.Barcode.QualityTests.ISO15416QualityTest
Requirements
Target Platforms: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
See Also