There is the WordRecognitionVariant object (IWordRecognitionVariant Interface) for each word in each converted IFRPage in FineReader Engine 12. To obtain the value of the word confidence level you can use the next possible sample code:
document.Process(null, null, null);
FREngine.ITextBlock 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++ ){
for( int Wordindex = 0; Wordindex < paragraphs[Parindex].Words.Count; Wordindex++ ) {
FREngine.IWordRecognitionVariants wrv = paragraphs[Parindex].Words[index].GetRecognitionVariants();
int recCounts = wrv.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("<<< " + wrv[recIndex].WordConfidence + " >>>");
}
}
}
}
}
}
FlexiCapture Engine 12 and FlexiCapture SDK 12 have similar algorithm to get recognition variants for word, but anyway there is sample for FCE12 and FC SDK12 with a few differences:
IEngine engine;
...
engine.EnableRecognitionVariants( true );
// Retrieving word recognition variants
IText text = field.Value.AsText;
IRecognizedWordInfo wordInfo = engine.CreateRecognizedWordInfo();
// Obtaining the main word recognition variant (the one which is used in the resulting text)
text.GetRecognizedWord( 0, -1, wordInfo );
// Iterating all word variants
for( int i = 0; i < wordInfo.RecognitionVariantsCount; i++ ) {
text.GetRecognizedWord( 0, i, wordInfo );
...
}
Comments
0 comments
Please sign in to leave a comment.