Класс KeyLineRecognizerCommand
Распознает зоны ключа на основе линий на изображении.
Вот C#/VB.NET код, который демонстрирует, как идентифицировать изображение документа с помощью алгоритма, который создает отпечаток изображения на основе линий.
''' <summary>
''' Identifies the image using key lines.
''' </summary>
''' <param name="templateImages">The template images.</param>
''' <param name="testImage">The test image.</param>
''' <returns>Result of template matching.</returns>
Public Shared Function IdentifyUsingLines(templateImages As Vintasoft.Imaging.VintasoftImage(), testImage As Vintasoft.Imaging.VintasoftImage) As Vintasoft.Imaging.FormsProcessing.TemplateMatching.TemplateMatchingResult
' create a recognizer
Dim lineRecognizerCommand As New Vintasoft.Imaging.FormsProcessing.TemplateMatching.KeyLineRecognizerCommand()
' set units of measure
lineRecognizerCommand.UnitOfMeasure = Vintasoft.Imaging.UnitOfMeasure.Pixels
' set max length of line
lineRecognizerCommand.MaxLength = 2000
' create a template matching command
Dim templateMatchingCommand As New Vintasoft.Imaging.FormsProcessing.TemplateMatching.TemplateMatchingCommand()
' set imprint generator based on recognizer
templateMatchingCommand.ImageImprintGenerator = New Vintasoft.Imaging.FormsProcessing.TemplateMatching.ImageImprintGeneratorCommand(lineRecognizerCommand)
' add template images
templateMatchingCommand.TemplateImages.AddRange(templateImages)
' execute template matching
templateMatchingCommand.ExecuteInPlace(testImage)
' return result
Return templateMatchingCommand.Result
End Function
/// <summary>
/// Identifies the image using key lines.
/// </summary>
/// <param name="templateImages">The template images.</param>
/// <param name="testImage">The test image.</param>
/// <returns>Result of template matching.</returns>
public static Vintasoft.Imaging.FormsProcessing.TemplateMatching.TemplateMatchingResult IdentifyUsingLines(
Vintasoft.Imaging.VintasoftImage[] templateImages,
Vintasoft.Imaging.VintasoftImage testImage)
{
// create a recognizer
Vintasoft.Imaging.FormsProcessing.TemplateMatching.KeyLineRecognizerCommand lineRecognizerCommand =
new Vintasoft.Imaging.FormsProcessing.TemplateMatching.KeyLineRecognizerCommand();
// set units of measure
lineRecognizerCommand.UnitOfMeasure = Vintasoft.Imaging.UnitOfMeasure.Pixels;
// set max length of line
lineRecognizerCommand.MaxLength = 2000;
// create a template matching command
Vintasoft.Imaging.FormsProcessing.TemplateMatching.TemplateMatchingCommand templateMatchingCommand =
new Vintasoft.Imaging.FormsProcessing.TemplateMatching.TemplateMatchingCommand();
// set imprint generator based on recognizer
templateMatchingCommand.ImageImprintGenerator =
new Vintasoft.Imaging.FormsProcessing.TemplateMatching.ImageImprintGeneratorCommand(lineRecognizerCommand);
// add template images
templateMatchingCommand.TemplateImages.AddRange(templateImages);
// execute template matching
templateMatchingCommand.ExecuteInPlace(testImage);
// return result
return templateMatchingCommand.Result;
}
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5