VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
Vintasoft.Imaging.ImageProcessing.Document Namespace / AutoTextOrientationCommand Class
Members Object Syntax Remarks Example Hierarchy Requirements SeeAlso
In This Topic
    AutoTextOrientationCommand Class
    In This Topic
    Automatically detects text orientation in a document image and rotates the image if necessary.
    Object Model
    ProcessingCommandBase ProcessingCommandResults AutoTextOrientationCommand
    Syntax
    'Declaration
    
    Public Class AutoTextOrientationCommand
       Inherits Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase
    
    
    public class AutoTextOrientationCommand : Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase
    
    
    public __gc class AutoTextOrientationCommand : public Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase*
    
    
    public ref class AutoTextOrientationCommand : public Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase^
    
    
    Remarks

    This processing command is designed to determine orientation of 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 rotated image. Use other processing commands prior to this command to improve detection quality of noisy image.

    Example

    This C#/VB.NET code shows how to load an image from disk, automatically correct the text orientation and save the result to the new image file.

    
    ''' <summary>
    ''' Applies auto text orientation and saves the result to the specified file.
    ''' </summary>
    ''' <param name="sourceFile">Source file.</param>
    ''' <param name="resultFile">Result file.</param>
    Public Sub ApplyAutoTextOrientation(sourceFile As String, resultFile As String)
        Using image As New Vintasoft.Imaging.VintasoftImage(sourceFile)
            ' create deskew command
            Dim deskew As New Vintasoft.Imaging.ImageProcessing.Document.DeskewCommand()
    
            ' create auto text orientation command
            Dim autoTextOrientation As New Vintasoft.Imaging.ImageProcessing.Document.AutoTextOrientationCommand()
    
            Try
                ' apply deskew command
                deskew.ExecuteInPlace(image)
    
                ' apply auto text orientation command
                autoTextOrientation.ExecuteInPlace(image)
            Catch ex As Vintasoft.Imaging.ImageProcessing.ImageProcessingException
                ' show error message if problem occured
                System.Windows.Forms.MessageBox.Show(ex.Message)
                Return
            End Try
    
            ' save the result image to file
            image.Save(resultFile)
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Applies auto text orientation and saves the result to the specified file.
    /// </summary>
    /// <param name="sourceFile">Source file.</param>
    /// <param name="resultFile">Result file.</param>
    public void ApplyAutoTextOrientation(string sourceFile, string resultFile)
    {
        using (Vintasoft.Imaging.VintasoftImage image =
            new Vintasoft.Imaging.VintasoftImage(sourceFile))
        {
            // create deskew command
            Vintasoft.Imaging.ImageProcessing.Document.DeskewCommand deskew =
                new Vintasoft.Imaging.ImageProcessing.Document.DeskewCommand();
    
            // create auto text orientation command
            Vintasoft.Imaging.ImageProcessing.Document.AutoTextOrientationCommand autoTextOrientation =
                new Vintasoft.Imaging.ImageProcessing.Document.AutoTextOrientationCommand();
    
            try
            {
                // apply deskew command
                deskew.ExecuteInPlace(image);
    
                // apply auto text orientation command
                autoTextOrientation.ExecuteInPlace(image);
            }
            catch (Vintasoft.Imaging.ImageProcessing.ImageProcessingException ex)
            {
                // show error message if problem occured
                System.Windows.Forms.MessageBox.Show(ex.Message);
                return;
            }
    
            // save the result image to file
            image.Save(resultFile);
        }
    }
    
    

    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.ImageProcessing.ProcessingCommandBase
          Vintasoft.Imaging.ImageProcessing.Document.AutoTextOrientationCommand

    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