VintaSoft Barcode .NET SDK 16.0: Руководство для .NET разработчика
Vintasoft.Barcode.QualityTests Namespace / QualityTestManager Class
Класс QualityTestManager
В этом разделе
Предоставляет менеджер тестов качества печати штрих-кодов ISO/IEC 15415 и ISO/IEC 15416.
Объектная модель
BarcodeReader ReaderSettings ISO15415QualityTestSettings ISO15415QualityTest ISO15416QualityTest QualityTestManager
Синтаксис
'Declaration

Public Class QualityTestManager

public class QualityTestManager

Ремарки

Для установки параметров проверки качества используется:

Пример

Вот пример, демонстрирующий, как проверить качество печати одномерных и/или двухмерных штрих-кодов:

   
   
Imports Vintasoft.Barcode   
Imports Vintasoft.Barcode.BarcodeInfo   
Imports Vintasoft.Barcode.QualityTests   
   
''' <summary>
''' Shows how to test print quality of 1D or 2D barcodes using QualityTestManger class.
''' </summary>
Class QualityTestManagerExample   
    ''' <summary>
    ''' Provides the manager of ISO/IEC 15415 and ISO/IEC 15416 barcode print quality tests.
    ''' </summary>
    Public Class MyQualityTestManager   
        Inherits QualityTestManager   
        ''' <summary>
        ''' Initializes a new instance of the <see cref="QualityTestManager"/> class.
        ''' </summary>
        ''' <param name="barcodeTypes">The barcode types to test print quality.</param>
        ''' <param name="expectedBarcodeCount">The expected number of barcodes to test.</param>
        Public Sub New(barcodeTypes As BarcodeType, expectedBarcodeCount As Integer)   
            MyBase.New(barcodeTypes, expectedBarcodeCount)   
            ' set ISO15415 settings
            ISO15415Settings.SetQuietZoneSize(BarcodeType.DataMatrix, 1)   
        End Sub   
   
        ''' <summary>
        ''' Creates the ISO15416 quality test settings.
        ''' </summary>
        ''' <param name="barcodeInfo">The barcode information.</param>
        ''' <returns>
        ''' A new instance of <see cref="T:Vintasoft.Barcode.QualityTests.ISO15416QualityTestSettings" /> class.
        ''' </returns>
        Protected Overrides Function CreateISO15416QualityTestSettings(barcodeInfo As BarcodeInfo1D) As ISO15416QualityTestSettings   
            ' set ISO15416 settings
            Dim result As ISO15416QualityTestSettings = MyBase.CreateISO15416QualityTestSettings(barcodeInfo)   
            If barcodeInfo.BarcodeType = BarcodeType.Code128 Then   
                result.LeftQuietZone = 10   
                result.RightQuietZone = 10   
            End If   
            Return result   
        End Function   
    End Class   
   
    ''' <summary>
    ''' Runs the quality test on image that contins single barcode.
    ''' </summary>
    ''' <param name="barcode">The barcode type.</param>
    ''' <param name="filename">The filename of image file.</param>
    Public Shared Sub Test(filename As String, barcode As BarcodeType)   
        Test(filename, barcode, 1)   
    End Sub   
   
    ''' <summary>
    ''' Runs the quality test on image that contins several barcode.
    ''' </summary>
    ''' <param name="barcodes">The barcode types.</param>
    ''' <param name="barcodeCount">Expected barcode count on image.</param>
    ''' <param name="filename">The filename of image file.</param>
    Public Shared Sub Test(filename As String, barcodes As BarcodeType, barcodeCount As Integer)   
        Using testManager As New MyQualityTestManager(barcodes, barcodeCount)   
            ' apertue factor = 0.8
            testManager.ApertureFactor = 0.8   
   
            ' barcode cell size (pixels) = undefined
            testManager.BarcodeCellAvgSize = 0   
   
            ' execute testing
            testManager.ExecuteTesting(filename)   
            Dim results1D As ISO15416QualityTest() = testManager.ISO15416Results   
            Dim results2D As ISO15415QualityTest() = testManager.ISO15415Results   
   
            If results1D.Length + results2D.Length = 0 Then   
                Console.WriteLine("No barcode found.")   
            Else   
                ' print results
                For Each testResult As ISO15416QualityTest In results1D   
                    Console.Write(Convert.ToString(testResult.BarcodeInfo.BarcodeType) & " = " & testResult.BarcodeInfo.Value & "; ")   
                    Console.WriteLine("Scan Grade = " & Convert.ToString(testResult.OverallSymbolGrade))   
                Next   
                For Each testResult As ISO15415QualityTest In results2D   
                    Console.Write(Convert.ToString(testResult.BarcodeInfo.BarcodeType) & " = " & testResult.BarcodeInfo.Value & "; ")   
                    Console.WriteLine("Scan Grade = " & Convert.ToString(testResult.OverallSymbolGrade))   
                Next   
            End If   
        End Using   
    End Sub   
End Class


using System;

using Vintasoft.Barcode;
using Vintasoft.Barcode.BarcodeInfo;
using Vintasoft.Barcode.QualityTests;

/// <summary>
/// Shows how to test print quality of 1D or 2D barcodes using QualityTestManger class.
/// </summary>
class QualityTestManagerExample
{
    /// <summary>
    /// Provides the manager of ISO/IEC 15415 and ISO/IEC 15416 barcode print quality tests.
    /// </summary>
    public class MyQualityTestManager: QualityTestManager
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="QualityTestManager"/> class.
        /// </summary>
        /// <param name="barcodeTypes">The barcode types to test print quality.</param>
        /// <param name="expectedBarcodeCount">The expected number of barcodes to test.</param>
        public MyQualityTestManager(BarcodeType barcodeTypes, int expectedBarcodeCount)
            : base(barcodeTypes, expectedBarcodeCount)  
        {
            // set ISO15415 settings
            ISO15415Settings.SetQuietZoneSize(BarcodeType.DataMatrix, 1);
        }

        /// <summary>
        /// Creates the ISO15416 quality test settings.
        /// </summary>
        /// <param name="barcodeInfo">The barcode information.</param>
        /// <returns>
        /// A new instance of <see cref="T:Vintasoft.Barcode.QualityTests.ISO15416QualityTestSettings" /> class.
        /// </returns>
        protected override ISO15416QualityTestSettings CreateISO15416QualityTestSettings(BarcodeInfo1D barcodeInfo)
        {
            // set ISO15416 settings
            ISO15416QualityTestSettings result = base.CreateISO15416QualityTestSettings(barcodeInfo);
            if (barcodeInfo.BarcodeType == BarcodeType.Code128)
            {
                result.LeftQuietZone = 10;
                result.RightQuietZone = 10;
            }
            return result;
        }
    }

    /// <summary>
    /// Runs the quality test on image that contins single barcode.
    /// </summary>
    /// <param name="barcode">The barcode type.</param>
    /// <param name="filename">The filename of image file.</param>
    public static void Test(string filename, BarcodeType barcode)
    {
        Test(filename, barcode, 1);
    }

    /// <summary>
    /// Runs the quality test on image that contins several barcode.
    /// </summary>
    /// <param name="barcodes">The barcode types.</param>
    /// <param name="barcodeCount">Expected barcode count on image.</param>
    /// <param name="filename">The filename of image file.</param>
    public static void Test(string filename, BarcodeType barcodes, int barcodeCount)
    {
        using (MyQualityTestManager testManager = new MyQualityTestManager(barcodes, barcodeCount))
        {
            // apertue factor = 0.8
            testManager.ApertureFactor = 0.8;

            // barcode cell size (pixels) = undefined
            testManager.BarcodeCellAvgSize = 0;

            // execute testing
            testManager.ExecuteTesting(filename);
            ISO15416QualityTest[] results1D = testManager.ISO15416Results;
            ISO15415QualityTest[] results2D = testManager.ISO15415Results;

            if (results1D.Length + results2D.Length == 0)
            {
                Console.WriteLine("No barcode found.");
            }
            else
            {
                // print results
                foreach (ISO15416QualityTest testResult in results1D)
                {
                    Console.Write(testResult.BarcodeInfo.BarcodeType + " = " + testResult.BarcodeInfo.Value + "; ");
                    Console.WriteLine("Scan Grade = " + testResult.OverallSymbolGrade);
                }
                foreach (ISO15415QualityTest testResult in results2D)
                {
                    Console.Write(testResult.BarcodeInfo.BarcodeType + " = " + testResult.BarcodeInfo.Value + "; ");
                    Console.WriteLine("Scan Grade = " + testResult.OverallSymbolGrade);
                }
            }
        }
    }
}

Иерархия наследования

System.Object
   Vintasoft.Barcode.QualityTests.QualityTestManager

Требования

Целевые платформы: .NET 10; .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

Смотрите также