当前位置: 首页>>代码示例>>C#>>正文


C# IEngine.CreateBlocksCollection方法代码示例

本文整理汇总了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" );
        }
开发者ID:DominatorCode,项目名称:FlexiCapture-Code-Snippets--C--,代码行数:56,代码来源:Advanced+techniques.cs


注:本文中的IEngine.CreateBlocksCollection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。