VintaSoft Imaging .NET SDK 14.0: Документация для .NET разработчика
Vintasoft.Imaging.ImageProcessing.Ocr.Tesseract Namespace / AutoTesseractOcrTextOrientationCommand Class
Члены типа Объект Синтаксис Example Иерархия Требования Смотрите также
В этом разделе
    Класс AutoTesseractOcrTextOrientationCommand
    В этом разделе
    Автоматически определяет ориентацию текста в изображении документа с помощью Tesseract OCR и при необходимости поворачивает изображение.
    Объектная модель
    ProcessingCommandResults AutoTesseractOcrTextOrientationCommand
    Синтаксис
    'Declaration
    
    Public Class AutoTesseractOcrTextOrientationCommand
       Inherits Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase
    
    
    public class AutoTesseractOcrTextOrientationCommand : Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase
    
    
    public __gc class AutoTesseractOcrTextOrientationCommand : public Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase*
    
    
    public ref class AutoTesseractOcrTextOrientationCommand : public Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase^
    
    
    Пример

    Вот C#/VB.NET код, который демонстрирует, как определить ориентацию изображения документа с помощью Tesseract OCR и сохранить изображение с правильной ориентацией страницы в новый файл изображения.

    
    ''' <summary>
    ''' Determines orientation of document image using Tesseract OCR and saves image with correct page orientation to a new image file.
    ''' </summary>
    ''' <param name="filename">The path to a file with document image.</param>
    ''' <param name="tesseractOcrDllDirectory">A path to a directory, where Tesseract5.Vintasoft.xXX.dll files are located.</param>
    Public Shared Sub DetermineDocumentImageOrientationUsingTesseractOCR(filename As String, tesseractOcrDllDirectory As String)
        ' create an image collection
        Using images As New Vintasoft.Imaging.ImageCollection()
            ' add images from file to the image collection
            images.Add(filename)
    
            ' create an instance of AutoTesseractOcrTextOrientationCommand class
            Using autoTextOrientationCommand As New Vintasoft.Imaging.ImageProcessing.Ocr.Tesseract.AutoTesseractOcrTextOrientationCommand()
                ' specify path to a directory, where Tesseract5.Vintasoft.xXX.dll files are located
                autoTextOrientationCommand.TesseractOcrDllDirectory = tesseractOcrDllDirectory
    
                ' for each image in image collection
                For i As Integer = 0 To images.Count - 1
                    ' get image
                    Dim image As Vintasoft.Imaging.VintasoftImage = images(i)
    
                    ' determine orientation of document image using Tesseract OCR
                    autoTextOrientationCommand.ExecuteInPlace(image)
    
                    image.Save(String.Format("image_with_correct_orientation-{0}.png", i))
                Next
            End Using
    
            ' free images
            images.ClearAndDisposeItems()
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Determines orientation of document image using Tesseract OCR and saves image with correct page orientation to a new image file.
    /// </summary>
    /// <param name="filename">The path to a file with document image.</param>
    /// <param name="tesseractOcrDllDirectory">A path to a directory, where Tesseract5.Vintasoft.xXX.dll files are located.</param>
    public static void DetermineDocumentImageOrientationUsingTesseractOCR(string filename, string tesseractOcrDllDirectory)
    {
        // create an image collection
        using (Vintasoft.Imaging.ImageCollection images = new Vintasoft.Imaging.ImageCollection())
        {
            // add images from file to the image collection
            images.Add(filename);
    
            // create an instance of AutoTesseractOcrTextOrientationCommand class
            using (Vintasoft.Imaging.ImageProcessing.Ocr.Tesseract.AutoTesseractOcrTextOrientationCommand autoTextOrientationCommand =
                new Vintasoft.Imaging.ImageProcessing.Ocr.Tesseract.AutoTesseractOcrTextOrientationCommand())
            {
                // specify path to a directory, where Tesseract5.Vintasoft.xXX.dll files are located
                autoTextOrientationCommand.TesseractOcrDllDirectory = tesseractOcrDllDirectory;
    
                // for each image in image collection
                for (int i = 0; i < images.Count; i++)
                {
                    // get image
                    Vintasoft.Imaging.VintasoftImage image = images[i];
    
                    // determine orientation of document image using Tesseract OCR
                    autoTextOrientationCommand.ExecuteInPlace(image);
    
                    image.Save(string.Format("image_with_correct_orientation-{0}.png", i));
                }
            }
    
            // free images
            images.ClearAndDisposeItems();
        }
    }
    
    

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

    System.Object
       Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase
          Vintasoft.Imaging.ImageProcessing.Ocr.Tesseract.AutoTesseractOcrTextOrientationCommand

    Требования

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

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