Community

FineReader WordConfidence bounds

Hello,

We are using the sample code from https://knowledgebase.ocrsdk.com/article/1443 to compute an average page confidence from FineReader 11.

Text in this picture

is recognized correctly. However, the engine returns negative values for the words SDK and Base (-7, -5) - outside the 0 - 100 bounds mentioned in the article.

 

Please advise if this is a good way to compute overall page confidence and how can we normalize these values.

 

Thank you,

Victor.

Was this article helpful?

0 out of 0 found this helpful

Comments

1 comment

  • Avatar
    Permanently deleted user

    Hi Victor,

    Thank you for your interest in our products!

     

    The WordConfidence property has sense only if other word recognition variants exist. It can be used only for comparison of two or more variants. In this case it doesn’t matter that the value is negative, it still can be compared with other values for other variant of this word. Please accept our apologies for the inconvinience. We should correct that article to clarify this moment. Thank you for your collaboration!

    Instead of WordConfidence I would advise you to use the CharConfidence property. At the stage of characters recognition there are more character variants then word variants at the stage of choosing the right word. So the CharRecognitionVariants object contains more then one variant and as a result CharConfidence can be used. 

    As for your issue, it may be useful for you to know these values:

    • Calculate confidence of each character variant

    • Get the CharParams::IsSuspicious property 

    Based on this values you may develop your own metrics depending on what is more important for your project.

     

    To calculate confidence of each character try to use the following code:

    FREngine.DocumentProcessingParams documentProcessingParams = engineLoader.Engine.CreateDocumentProcessingParams();

      documentProcessingParams.PageProcessingParams.RecognizerParams.SaveCharacterRecognitionVariants = true;

                    documentProcessingParams.PageProcessingParams.RecognizerParams.ExactConfidenceCalculation = true;

                    document.Process(documentProcessingParams);

                    FREngine.TextBlock textBlock = null;

     

                    for (int i = 0; i < document.Pages.Count; i++)

                    {

     

                        FREngine.ILayout layout = document.Pages[i].Layout;

                        FREngine.ILayoutBlocks blocks = layout.Blocks;

     

                        for (int index = 0; index < blocks.Count; index++)

                        {

     

                            if (blocks[index].Type == FREngine.BlockTypeEnum.BT_Text)

     

                                textBlock = blocks[index].GetAsTextBlock();

                            FREngine.IParagraphs paragraphs = textBlock.Text.Paragraphs;

     

                            for (int Parindex = 0; Parindex < paragraphs.Count; Parindex++)

                            {

                                MessageBox.Show(paragraphs[Parindex].Text);

                                for (int Charindex = 0; Charindex < paragraphs[Parindex].Text.Length; Charindex++)

                                {

                                    if (paragraphs[Parindex].Text[Charindex] != ' ')

                                    {

                                        FREngine.CharParams charParams = engineLoader.Engine.CreateCharParams();

                                        paragraphs[Parindex].GetCharParams(Charindex, charParams);

     

                                        FREngine.ICharacterRecognitionVariants crv = charParams.CharacterRecognitionVariants;

                                        int recCounts = crv.Count;

     

                                        for (int recIndex = 0; recIndex < recCounts; recIndex++)

                                        {

     

                                            //this is only a demonstration of the obtaining this value. 

                                            //Please modify it according to your purposes.

                                            MessageBox.Show(crv[recIndex].Character + " <<< " + crv[recIndex].CharConfidence + " >>>");

                                        }

                                    }

                                }

                            }

                        }

                    }

     

    Hope it will help you!

    0

Please sign in to leave a comment.