本文整理汇总了C#中IEngine.CreateBlocksCollection方法的典型用法代码示例。如果您正苦于以下问题:C# IEngine.CreateBlocksCollection方法的具体用法?C# IEngine.CreateBlocksCollection怎么用?C# IEngine.CreateBlocksCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEngine
的用法示例。
在下文中一共展示了IEngine.CreateBlocksCollection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Single_click_field_text_extraction
// USE CASE: Single click field text extraction
public static void Single_click_field_text_extraction( IEngine engine )
{
// We want to implement a feature allowing the user of our application to
// match fields on the page by simply clicking on the text in the image.
trace( "Create a sample document..." );
IDocument document = PrepareNewRecognizedDocument( engine );
trace( "Extract all background text regions on a page..." );
IPage page = document.Pages[0];
ITextRegions textRegions = page.ExtractTextRegions();
traceBegin( "Create a list of found text regions..." );
for( int i = 0; i < textRegions.Count; i++ ) {
ITextRegion textRegion = textRegions[i];
string text = textRegion.Text.Text;
IRectangle r = textRegion.Region.BoundingRectangle;
trace( string.Format( "'{0}' - [{1},{2},{3},{4}]", text, r.Left, r.Top, r.Right, r.Bottom ) );
}
traceEnd( "" );
// Now it is quite simple to implement the desired behavior.
// Suppose the user 'sees' the word 'ENGLAND' and clicks on it.
// In this sample we find the clicked region by text, in a real
// application we would find it as containing the clicked point
ITextRegion clickedRegion = null;
for( int i = 0; i < textRegions.Count; i++ ) {
ITextRegion textRegion = textRegions[i];
if( textRegion.Text.Text == "ENGLAND" ) {
clickedRegion = textRegion;
break;
}
}
assert( clickedRegion != null );
// In our implementation we can either use the prerecognized text for the region (which is
// fast and usually quite accurate) or set the required field region to enclose the found text
// region and rerecognize the field to apply field-specific recognition parameters:
IField theField = document.Sections[0].Children[2];
assert( theField.Name == "DeliveryAddress" );
IBlock theBlock = theField.Blocks[0];
IRegion newRegion = engine.CreateRegion();
IRectangle br = clickedRegion.Region.BoundingRectangle;
newRegion.AddRect( br.Left, br.Top, br.Right, br.Bottom );
theBlock.Region = newRegion;
IBlocksCollection blocksToRerecognize = engine.CreateBlocksCollection();
blocksToRerecognize.Add( theBlock );
document.RecognizeBlocks( blocksToRerecognize );
assert( theField.Value.AsString == "ENGLAND" );
}