Community

How to Recognizing Handprinted Texts Answered

Hello. I am troubled with handwriting recognition.
I implemented it in C # by referring to "Recognizing Handprinted Texts" in Help, but I can not properly recognize handwriting.
What is wrong with my code?

The target is English, numbers.
Also attach the target file you want to recognize.

 

Was this article helpful?

0 out of 0 found this helpful

Comments

3 comments

  • Avatar
    OHTSUKA Takeshi

    Source Code

    // Engine Load
    ...

    FRDocument document = engine.CreateFRDocument();
    document.AddImageFile(strImagePath, null, null);

    FREngine.Layout layout = engine.CreateLayout();
    // Set block region
    FREngine.Region region = engine.CreateRegion();
    region.AddRect(70, 106, 256, 129);
    // Create a new block
    FREngine.IBlock newBlock = layout.Blocks.AddNew(FREngine.BlockTypeEnum.BT_Text, region, 0);
    FREngine.TextBlock textBlock = newBlock.GetAsTextBlock();
    // Specify the text type
    textBlock.RecognizerParams.TextTypes = (int)FREngine.TextTypeEnum.TT_Handprinted;
    // Specify the type of marking around the letters
    textBlock.RecognizerParams.FieldMarkingType = FREngine.FieldMarkingTypeEnum.FMT_SimpleText;

    // GetParameter
    DocumentProcessingParams dpp = engine.CreateDocumentProcessingParams();
    dpp.PageProcessingParams.RecognizerParams.SetPredefinedTextLanguage("Japanese,English");
    dpp.SynthesisParamsForDocument.FontSet.SystemFontSet.FontNamesFilter = (int)FontNamesFiltersEnum.FNF_Japanese;
    dpp.PageProcessingParams.PagePreprocessingParams.CorrectOrientation = true;
    dpp.PageProcessingParams.PagePreprocessingParams.OrientationDetectionParams.OrientationDetectionMode = OrientationDetectionModeEnum.ODM_Normal;
    dpp.PageProcessingParams.ObjectsExtractionParams.SourceContentReuseMode = SourceContentReuseModeEnum.CRM_Auto;
    dpp.PageProcessingParams.ObjectsExtractionParams.DetectTextOnPictures = true;
    dpp.PageProcessingParams.ObjectsExtractionParams.EnableAggressiveTextExtraction = true;
                   
    // Process
    document.Process(dpp);

    // PDF Export
    FREngine.PDFExportParams pdfParams = engine.CreatePDFExportParams();
    pdfParams.Scenario = FREngine.PDFExportScenarioEnum.PES_Balanced;
    document.Export(strPDFPath, FREngine.FileExportFormatEnum.FEF_PDF, pdfParams);

    // Engine Unload
    ...

    0
  • Avatar
    Daria Zvereva

    Hello!

    First of all, automatic layout analysis is not available for handprinted text. The coordinates of each block containing handprinted text must be specified manually. 

    In your code there are two issues: 

    • The rectangle coordinates (70, 106, 256, 129) are not selected correctly. You may see this rectangle in the file attached, it does not include any text. The coordinates of the rectangle must be the same as its coordinates on the image in pixels and should be specified relative to the left top corner of the image. 
    • The layout created in the beginning is not connected with your document. To fix it you should replace the document layout with the new one.

    Please check the following C# code sample showing how to recognize the first field of your document.

    // Get layout of the first page
    FREngine.FRPages pages = document.Pages;
    FREngine.FRPage page = pages.Item(0);
    FREngine.Layout layout = page.Layout;
    // Set block region
    FREngine.Region region = engineLoader.Engine.CreateRegion();
    region.AddRect(200, 300, 700, 356);
    // Create a new block
    FREngine.IBlock newBlock = layout.Blocks.AddNew(FREngine.BlockTypeEnum.BT_Text, region, 0);
    FREngine.TextBlock textBlock = newBlock.GetAsTextBlock();
    // Specify the text type
    textBlock.RecognizerParams.TextTypes = (int)FREngine.TextTypeEnum.TT_Handprinted;
    textBlock.RecognizerParams.SetPredefinedTextLanguage("Digits");
    // Specify the type of marking around the letters
    textBlock.RecognizerParams.FieldMarkingType = FREngine.FieldMarkingTypeEnum.FMT_SimpleText;
    textBlock.RecognizerParams.WritingStyle = FREngine.WritingStyleEnum.WS_Japanese;
    // Replace page in the document with the new one
    page.Layout = layout;
    document.Pages.DeleteAt(0);
    document.AddPage(page);
    // Process
    document.Recognize( null, null );
    document.Synthesize( null );

    Hope the information will be helpful!

    1
  • Avatar
    OHTSUKA Takeshi

    Hello.

    Thank you for your reply and source code.
    You create a new layout from the page and set it there.
    Because it was a detailed explanation, it was easy to understand and it was very helpful.
    I will challenge other acquisition based on this information.

    0

Please sign in to leave a comment.