本文整理汇总了C#中IEngine.CreateRecognizedCharacterInfo方法的典型用法代码示例。如果您正苦于以下问题:C# IEngine.CreateRecognizedCharacterInfo方法的具体用法?C# IEngine.CreateRecognizedCharacterInfo怎么用?C# IEngine.CreateRecognizedCharacterInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEngine
的用法示例。
在下文中一共展示了IEngine.CreateRecognizedCharacterInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Using_recognition_variants_and_extended_character_info
// USE CASE: Using recognition variants and extended character info
public static void Using_recognition_variants_and_extended_character_info( IEngine engine )
{
trace( "Enable recognition variants..." );
engine.EnableRecognitionVariants( true );
trace( "Prepare a sample document..." );
IDocument document = PrepareNewRecognizedDocument( engine );
trace( "Find the field of interest..." );
IField field = findField( document, "InvoiceNumber" );
assert( field != null );
traceBegin( "Show word variants..." );
// (1) You might want to use word variants if you know how to choose the correct result
// and this knowledge cannot be communicated to the engine (in the form of a regular expression
// or dictionary) or if you decide that you can do the selection better.
// EXAMPLES: (1) a field containing some code with a checksum (2) a field that can be looked up
// in a database (3) a field that can be crosschecked with another field in the same document
IText text = field.Value.AsText;
assert( text.RecognizedWordsCount == 1 );
IRecognizedWordInfo wordInfo = engine.CreateRecognizedWordInfo();
// Get the recognition info for the first word. Thus we'll know the number of available variants
text.GetRecognizedWord( 0, -1, wordInfo );
for( int i = 0; i < wordInfo.RecognitionVariantsCount; i++ ) {
// Get the specified recognition variant for the word
text.GetRecognizedWord( 0, i, wordInfo );
trace( wordInfo.Text );
}
traceEnd( "" );
traceBegin( "Show char variants for each word variant..." );
// (2) You can use a more advanced approach and build your own hypotheses from variants
// for individual characters. This approach can be very computationally intensive, so use it with care.
// Use word/char variant confidence to limit the number of built hypotheses
IRecognizedCharacterInfo charInfo = engine.CreateRecognizedCharacterInfo();
for( int k = 0; k < wordInfo.RecognitionVariantsCount; k ++ ) {
// For each variant of the first word
text.GetRecognizedWord( 0, k, wordInfo );
traceBegin( wordInfo.Text );
for( int i = 0; i < wordInfo.Text.Length; i++ ) {
// Get the recognition info for the first character (the number of available variants)
wordInfo.GetRecognizedCharacter( i, -1, charInfo );
string charVars = "";
for( int j = 0; j < charInfo.RecognitionVariantsCount; j++ ) {
// Get the specified recognition variant for the character. The variant may contain
// more than one character if the geometry in the specified position can be interpreted
// as several merged characters. For example, something which looks like poorly printed 'U'
// can actually be a pair of merged 'I'-s or 'I' + 'J'
wordInfo.GetRecognizedCharacter( i, j, charInfo );
if( charInfo.CharConfidence > 50 ) {
charVars += charInfo.Character.PadRight( 4, ' ' );
}
}
trace( charVars );
}
traceEnd( "" );
}
traceEnd( "" );
traceBegin( "Linking text in the field to recognition variants..." );
// (3) You can find corresponding recognition word and character variants for each character in the text
// even if the text has been modified. This can be helpful in building your own advanced verification tools
// where users can choose variants for words while typing or from a list
ICharParams charParams = engine.CreateCharParams();
for( int i = 0; i < text.Length; i++ ) {
text.GetCharParams( i, charParams );
trace( string.Format( "'{0}' is char number {1} in word number {2}", text.Text[i],
charParams.RecognizedWordCharacterIndex, charParams.RecognizedWordIndex ) );
}
traceEnd( "" );
traceBegin( "Obtaining extended char information for characters in text..." );
// (4) You can obtain extended char info for a character in the text without getting involved deeply in
// the recognition variants API by means of the shortcut method GetCharParamsEx
for( int i = 0; i < text.Length; i++ ) {
text.GetCharParamsEx( i, charParams, charInfo );
trace( string.Format( "'{0}' serif probability is {1}", charInfo.Character, charInfo.SerifProbability ) );
}
traceEnd( "" );
// Restore the initial state of the engine. It is optional and should not be done if you always
// use recognition variants. Doing so will reset some internal caches and if done repeatedly
// might affect performance
engine.EnableRecognitionVariants( false );
}