VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
Vintasoft.Imaging.ImageProcessing.Info Namespace / GetTextOrientationCommand Class
Members Object Syntax Remarks Example Hierarchy Requirements SeeAlso
In This Topic
    GetTextOrientationCommand Class
    In This Topic
    Detects text orientation in a document image.
    Object Model
    ProcessingCommandBase ProcessingCommandResults GetTextOrientationCommand
    Syntax
    'Declaration
    
    Public Class GetTextOrientationCommand
       Inherits Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase
    
    
    public class GetTextOrientationCommand : Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase
    
    
    public __gc class GetTextOrientationCommand : public Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase*
    
    
    public ref class GetTextOrientationCommand : public Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase^
    
    
    Remarks

    This processing command is designed to determine orientation of document images containing mostly text in Roman alphabet which is rotated by multiple of 90 degrees (e.g., scanned documents with unknown orientation).
    The command is not designed for:

    • non-textual images
    • non-Roman text
    • Roman text with only capital letters
    • rotated text with rotation angle other than multiple of 90 degrees (use DeskewCommand)
    • images with only few words, insufficient for making a conclusion.

    Use DeskewCommand prior to this command to align the rotated image. Use other processing commands prior to this command to improve the detection quality of image with noise.

    Example

    This C#/VB.NET code shows how to load an image from disk and determine the text orientation.

    
    ''' <summary>
    ''' Returns an orientation angle of document image using statistics for Latin symbols.
    ''' </summary>
    ''' <param name="filename">The path to a file with document image.</param>
    Public Shared Sub GetDocumentImageOrientationUsingLatinSymbolStat(filename 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 GetTextOrientationCommand class
            Dim getTextOrientationCommand1 As New Vintasoft.Imaging.ImageProcessing.Info.GetTextOrientationCommand()
    
            ' 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 statistics for Latin symbols
                getTextOrientationCommand1.ExecuteInPlace(image)
    
                ' write result to the console
                System.Console.WriteLine(String.Format("Filename: {0}, page: {1}, page orientation: {2}, confidence: {3}", System.IO.Path.GetFileName(filename), i, getTextOrientationCommand1.Orientation, getTextOrientationCommand1.Confidence))
            Next
    
            ' free images
            images.ClearAndDisposeItems()
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Returns an orientation angle of document image using statistics for Latin symbols.
    /// </summary>
    /// <param name="filename">The path to a file with document image.</param>
    public static void GetDocumentImageOrientationUsingLatinSymbolStat(string filename)
    {
        // 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 GetTextOrientationCommand class
            Vintasoft.Imaging.ImageProcessing.Info.GetTextOrientationCommand getTextOrientationCommand1 =
                new Vintasoft.Imaging.ImageProcessing.Info.GetTextOrientationCommand();
    
            // 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 statistics for Latin symbols
                getTextOrientationCommand1.ExecuteInPlace(image);
    
                // write result to the console
                System.Console.WriteLine(string.Format("Filename: {0}, page: {1}, page orientation: {2}, confidence: {3}",
                    System.IO.Path.GetFileName(filename),
                    i,
                    getTextOrientationCommand1.Orientation,
                    getTextOrientationCommand1.Confidence));
            }
    
            // free images
            images.ClearAndDisposeItems();
        }
    }
    
    

    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase
          Vintasoft.Imaging.ImageProcessing.Info.GetTextOrientationCommand

    Requirements

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

    See Also