VintaSoft Imaging .NET SDK 11.0
Vintasoft.Imaging.ImageProcessing.Ocr.Tesseract Namespace / GetTesseractOcrTextOrientationCommand Class
Members Example



In This Topic
    GetTesseractOcrTextOrientationCommand Class
    In This Topic
    Detects text orientation in a document image using Tesseract OCR.
    Object Model
    GetTesseractOcrTextOrientationCommand ClassRegionOfInterest ClassProcessingCommandResults ClassProcessingCommandResult Class
    Syntax
    'Declaration
     
    Public Class GetTesseractOcrTextOrientationCommand 
       Inherits Vintasoft.Imaging.ImageProcessing.ProcessingCommandWithRegion
    public class GetTesseractOcrTextOrientationCommand : Vintasoft.Imaging.ImageProcessing.ProcessingCommandWithRegion 
    public __gc class GetTesseractOcrTextOrientationCommand : public Vintasoft.Imaging.ImageProcessing.ProcessingCommandWithRegion 
    public ref class GetTesseractOcrTextOrientationCommand : public Vintasoft.Imaging.ImageProcessing.ProcessingCommandWithRegion 
    Remarks
    This command creates an instance of Vintasoft.Imaging.Ocr.Tesseract.TesseractOcr class in the ProcessImageInPlace method. Created instance of Vintasoft.Imaging.Ocr.Tesseract.TesseractOcr class is destroyed in Dispose method.
    Use the same instance of this class if it is necessary to process several images.
    Example
    This example 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 6; .NET 5; .NET Core 3.1; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also