Community

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

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#?

3

Comments

5 comments

  • Avatar
    Julia Anikushina

    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.

    4
  • Avatar
    PhilippWuelfing

    What could be the reason if no text is recognized?

    I have a simple pdf file with 2 words of text.

    I am trying for days to get any text recognized.

    I already tried all possible ways using Engine, FRDocument and DocumentAnalyzer.

    0
  • Avatar
    Florian Hallensleben

    I don't know about FRE10 but in FRE11 it's not

    region.AddRect(Right,Top,Left,Bottom);

    but

    region.AddRect(Left,Top,Right,Bottom);

     

    0
  • Avatar
    Denis Gusak

    Hi!

    We need a little bit more information in order to help you.

    Can you please provide images you are trying to recognize and a piece of code that demonstrates how are you using FineReader Engine? You can post it here or send it to SDK_Support@abbyy.com.

    Also have you tried samples that comes with FineReader Engine with your pdf? 

    0
  • Avatar
    PhilippWuelfing

    Hi,

    I solved this issue as described in this thread: 

    https://forum.ocrsdk.com/thread/layout-file/?order=all#comment-ae93f5d9-9057-4c68-82f9-a82d00a71632

     

    Solution was to set the language for the RecognizerParams of the TextBlock.

    0

Please sign in to leave a comment.