VintaSoft Imaging .NET SDK 15.1: Documentation for .NET developer
Vintasoft.Imaging.ImageProcessing.Ocr.Tesseract Namespace / GetTesseractOcrTextOrientationCommand Class
Members Object Syntax Remarks Example Hierarchy Requirements SeeAlso
In This Topic
GetTesseractOcrTextOrientationCommand Class
In This Topic
Detects text orientation in a document image using Tesseract OCR.
Object Model
RegionOfInterest ProcessingCommandResults GetTesseractOcrTextOrientationCommand
Syntax
'Declaration

Public Class GetTesseractOcrTextOrientationCommand
   Inherits Vintasoft.Imaging.ImageProcessing.ProcessingCommandWithRegion

public class GetTesseractOcrTextOrientationCommand : Vintasoft.Imaging.ImageProcessing.ProcessingCommandWithRegion

Remarks

This command creates an instance of TesseractOcr class in the ProcessImageInPlace method. Created instance of TesseractOcr class is destroyed in Dispose method.
Use the same instance of this class if it is necessary to process several images.

Example

This C#/VB.NET code shows how to get an orientation angle of document image using Tesseract OCR.


''' <summary>
''' Returns an orientation angle of document image using Tesseract OCR.
''' </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 GetDocumentImageOrientationUsingTesseractOCR(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 GetTesseractOcrTextOrientationCommand class
        Using getTextOrientationCommand As New Vintasoft.Imaging.ImageProcessing.Ocr.Tesseract.GetTesseractOcrTextOrientationCommand()
            ' specify path to a directory, where Tesseract5.Vintasoft.xXX.dll files are located
            getTextOrientationCommand.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
                getTextOrientationCommand.ExecuteInPlace(image)

                ' write result to the console
                System.Console.WriteLine(String.Format("Filename: {0}, page: {1}, page orientation: {2}", System.IO.Path.GetFileName(filename), i, getTextOrientationCommand.Orientation))
            Next
        End Using

        ' free images
        images.ClearAndDisposeItems()
    End Using
End Sub


/// <summary>
/// Returns an orientation angle of document image using Tesseract OCR.
/// </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 GetDocumentImageOrientationUsingTesseractOCR(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 GetTesseractOcrTextOrientationCommand class
        using (Vintasoft.Imaging.ImageProcessing.Ocr.Tesseract.GetTesseractOcrTextOrientationCommand getTextOrientationCommand =
            new Vintasoft.Imaging.ImageProcessing.Ocr.Tesseract.GetTesseractOcrTextOrientationCommand())
        {
            // specify path to a directory, where Tesseract5.Vintasoft.xXX.dll files are located
            getTextOrientationCommand.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
                getTextOrientationCommand.ExecuteInPlace(image);

                // write result to the console
                System.Console.WriteLine(string.Format("Filename: {0}, page: {1}, page orientation: {2}",
                    System.IO.Path.GetFileName(filename),
                    i,
                    getTextOrientationCommand.Orientation));
            }
        }

        // free images
        images.ClearAndDisposeItems();
    }
}

Inheritance Hierarchy

System.Object
   Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase
      Vintasoft.Imaging.ImageProcessing.ProcessingCommandWithRegion
         Vintasoft.Imaging.ImageProcessing.Ocr.Tesseract.GetTesseractOcrTextOrientationCommand

Requirements

Target Platforms: .NET 10; .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

See Also