[FR10 Engine] How to only recognize specified region of the image?

  • 4K Views
  • Last Post 05 November 2013
  • Topic Is Solved
Alexander Smirnov posted this 05 November 2013

Hello, i need to recognize only specified region of the image file as i think this will speed up recognition process. I have Top, Left, Right, Bottom coordinates. How can i do that using FREngine10 API for c#?

Julia Anikushina posted this 05 November 2013

To recognize only specified region you can create a Layout object and add blocks manually:

  1. Create a Layout object with the help of the CreateLayout method of the Engine object or obtain the Layout object, which corresponds to the page, via the IFRPage::Layout property.
  2. Create a Region object for the block using the IEngine::CreateRegion method and add rectangles to it using the IRegion::AddRect method.
  3. Create a block of required type and add it into the collection using the AddBlock method of the Layout object.
  4. Set the required parameters of the block (use the block properties object corresponding to the type of block).

C# sample:

// Create document and open image
FREngine.FRDocument document = engineLoader.Engine.CreateFRDocument();
document.AddImageFile( imagePath, null, null );

// Remove all the blocks from the collection
document.Pages[0].Layout.Blocks.RemoveAll();

// Create region and specify its coordinates
FREngine.Region region = engineLoader.Engine.CreateRegion(); 
region.AddRect(Right,Top,Left,Bottom);

// Add blocks of required type to the layout
document.Pages[0].Layout.AddBlock(FREngine.BlockTypeEnum.BT_Barcode, region);

// Set the required parameters of the block
FREngine.TextOrientation textOrientation = engineLoader.Engine.CreateTextOrientation(); 
textOrientation.RotationType = FREngine.RotationTypeEnum.RT_Counterclockwise; 
document.Pages[0].Layout.Blocks[0].GetAsBarcodeBlock().TextOrientation = textOrientation;

//Recognize document
document.Recognize( null, null );

For detailed information about these methods please refer to Developer’s Help.

Close