To recognize pages that contain text with different orientations (like on image below), you can explicitly specify the text orientation and its coordinates.
To implement this:
- Create text blocks for the text in the image.
- Specify the text orientation using TextOrientation object.
- Call the Recognize method of the FRDocument object.
C# sample:
//add your image to the FRDocument
string imagePath = @"D:\SampleImages\orientations.png";
document.AddImageFile(imagePath, null, null);
//create regions that correspond to the text
FREngine.Region verticalRegion = engineLoader.Engine.CreateRegion();
verticalRegion.AddRect(88,110,128,245); //specify vertical text coordinates
FREngine.Region horizontalRegion = engineLoader.Engine.CreateRegion();
horizontalRegion.AddRect(90,354,252,390); //specify horizontal text coordinates
//add text blocks to document layout
document.Pages[0].Layout.AddBlock(FREngine.BlockTypeEnum.BT_Text, horizontalRegion);
document.Pages[0].Layout.AddBlock(FREngine.BlockTypeEnum.BT_Text, verticalRegion);
//specify orientation for vertical text
FREngine.TextOrientation textOrientation = engineLoader.Engine.CreateTextOrientation();
textOrientation.RotationType = FREngine.RotationTypeEnum.RT_Counterclockwise;
document.Pages[0].Layout.Blocks[1].GetAsTextBlock().TextOrientation = textOrientation;
//recognize, synthesize, export
document.Recognize();
document.Synthesize();
document.Export(@"D:\Results\exp.rtf", FREngine.FileExportFormatEnum.FEF_RTF, null);
To run this sample, you can insert the code above into the try block of the processImage method in C# Hello sample and specify the path to the attached image.
Comments
0 comments
Please sign in to leave a comment.