VintaSoft Imaging .NET SDK v8.7
Vintasoft.Imaging.ImageProcessing.Info Namespace / GetTextOrientationCommand Class
Members Example



In This Topic
    GetTextOrientationCommand Class
    In This Topic
    Detects text orientation in a document image.
    Object Model
    GetTextOrientationCommand ClassProcessingCommandBase ClassProcessingCommandResults ClassProcessingCommandResult Class
    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 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:

    Use Vintasoft.Imaging.ImageProcessing.Document.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 example shows how to load an image from disk and determine the text orientation.
    ' [ do not forget to set your image file path here! ]
    Dim filepath As String = "Document.tif"
                
    ' create the command
    Dim command As New Vintasoft.Imaging.ImageProcessing.Info.GetTextOrientationCommand()
                
    ' initialize command results
    command.Results = New Vintasoft.Imaging.ImageProcessing.ProcessingCommandResults()
                
    Try
    	Using image As New Vintasoft.Imaging.VintasoftImage(filepath)
    		' execute the command
    		command.ExecuteInPlace(image)
    	End Using
    Catch ex As Vintasoft.Imaging.ImageProcessing.ImageProcessingException
    	' show error message if problem occured
    	System.Windows.Forms.MessageBox.Show(ex.Message)
    	Return
    End Try
                
    ' get command result
    Dim result As Vintasoft.Imaging.ImageProcessing.Info.GetTextOrientationCommandResult = DirectCast(command.Results(0), Vintasoft.Imaging.ImageProcessing.Info.GetTextOrientationCommandResult)
    Dim documentOrientation As Vintasoft.Imaging.ImageProcessing.Info.ImageOrthogonalOrientation = result.Orientation
                
    ' show orientation determining result
    Select Case documentOrientation
    	Case Vintasoft.Imaging.ImageProcessing.Info.ImageOrthogonalOrientation.Undefined
    		System.Windows.Forms.MessageBox.Show(System.[String].Format("Document orientation is not defined."))
    		Exit Select
    	Case Vintasoft.Imaging.ImageProcessing.Info.ImageOrthogonalOrientation.Rotated0
    		System.Windows.Forms.MessageBox.Show(System.[String].Format("Document has the right orientation."))
    		Exit Select
    	Case Vintasoft.Imaging.ImageProcessing.Info.ImageOrthogonalOrientation.Rotated90
    		System.Windows.Forms.MessageBox.Show(System.[String].Format("Document is rotated by 90 degrees clockwise."))
    		Exit Select
    	Case Vintasoft.Imaging.ImageProcessing.Info.ImageOrthogonalOrientation.Rotated180
    		System.Windows.Forms.MessageBox.Show(System.[String].Format("Document is rotated by 180 degrees clockwise."))
    		Exit Select
    	Case Vintasoft.Imaging.ImageProcessing.Info.ImageOrthogonalOrientation.Rotated270
    		System.Windows.Forms.MessageBox.Show(System.[String].Format("Document is rotated by 270 degrees clockwise."))
    		Exit Select
    	Case Else
    		Throw New System.NotImplementedException()
    End Select
    // [ do not forget to set your image file path here! ]
    string filepath = "Document.tif";
                
    // create the command
    Vintasoft.Imaging.ImageProcessing.Info.GetTextOrientationCommand command =
        new Vintasoft.Imaging.ImageProcessing.Info.GetTextOrientationCommand();
                
    // initialize command results
    command.Results = new Vintasoft.Imaging.ImageProcessing.ProcessingCommandResults();
                
    try
    {
        using (Vintasoft.Imaging.VintasoftImage image = 
            new Vintasoft.Imaging.VintasoftImage(filepath))
        {
            // execute the command
            command.ExecuteInPlace(image);
        }
    }
    catch (Vintasoft.Imaging.ImageProcessing.ImageProcessingException ex)
    {
        // show error message if problem occured
        System.Windows.Forms.MessageBox.Show(ex.Message);
        return;
    }
                
    // get command result
    Vintasoft.Imaging.ImageProcessing.Info.GetTextOrientationCommandResult result = 
        (Vintasoft.Imaging.ImageProcessing.Info.GetTextOrientationCommandResult)command.Results[0];
    Vintasoft.Imaging.ImageProcessing.Info.ImageOrthogonalOrientation documentOrientation = 
        result.Orientation;
                
    // show orientation determining result
    switch (documentOrientation)
    {
        case Vintasoft.Imaging.ImageProcessing.Info.ImageOrthogonalOrientation.Undefined: 
            System.Windows.Forms.MessageBox.Show(System.String.Format("Document orientation is not defined."));
            break;
        case Vintasoft.Imaging.ImageProcessing.Info.ImageOrthogonalOrientation.Rotated0:
            System.Windows.Forms.MessageBox.Show(System.String.Format("Document has the right orientation."));
            break;
        case Vintasoft.Imaging.ImageProcessing.Info.ImageOrthogonalOrientation.Rotated90:
            System.Windows.Forms.MessageBox.Show(System.String.Format("Document is rotated by 90 degrees clockwise."));
            break;
        case Vintasoft.Imaging.ImageProcessing.Info.ImageOrthogonalOrientation.Rotated180:
            System.Windows.Forms.MessageBox.Show(System.String.Format("Document is rotated by 180 degrees clockwise."));
            break;
        case Vintasoft.Imaging.ImageProcessing.Info.ImageOrthogonalOrientation.Rotated270:
            System.Windows.Forms.MessageBox.Show(System.String.Format("Document is rotated by 270 degrees clockwise."));
            break;
        default:
            throw new System.NotImplementedException();
    }
    Inheritance Hierarchy

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

    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also