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


C# IEngine.CreateFlexiCaptureProcessor方法代码示例

本文整理汇总了C#中IEngine.CreateFlexiCaptureProcessor方法的典型用法代码示例。如果您正苦于以下问题:C# IEngine.CreateFlexiCaptureProcessor方法的具体用法?C# IEngine.CreateFlexiCaptureProcessor怎么用?C# IEngine.CreateFlexiCaptureProcessor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEngine的用法示例。


在下文中一共展示了IEngine.CreateFlexiCaptureProcessor方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: How_to_explicitly_release_a_COM_object_from_managed_code

        // HOW-TO: Explicitly release a COM object from managed code
        public static void How_to_explicitly_release_a_COM_object_from_managed_code( IEngine engine )
        {
            // When using COM objects from managed code, it is sometimes
            // required to ensure that a COM object is released at a specific point
            // and not left to the garbage collector (which might not
            // release the object for a long time). This might be needed to release
            // memory or other resources taken by the object if there is no other
            // way to release them. This is effectively "DISPOSAL" of the COM object and
            // the same rules should be followed as those used when deciding if
            // Dispose method should be called on a disposable .NET Framework object.

            // Releasing resources in timely manner is especially important in
            // server applications. Garbage collector does not "know" the real
            // amount of memory and resources used by COM objects and will
            // not "know" that they should be garbage-collected. As the result, your server
            // application might run low on non-managed memory while managed heap
            // will be still almost empty and garbage-collection will not run.

            // For example, the FlexiCapture processor object has some internal state,
            // which consumes resources. If we just leave the object to the garbage
            // collector, we cannot be sure when these resources are released.
            // It might not be a problem in most cases, but if our application
            // is to be used in high-performance scenarios we'd be better off
            // explicitly releasing the object. The downside of this scenario is
            // the complexity of the resulting code.

            trace( "Create a COM object..." );
            IFlexiCaptureProcessor processor = engine.CreateFlexiCaptureProcessor();
            try {
                // Some processing here
                // ...
            } finally {
                trace( "To explicitly release the COM object, call Marshal.ReleaseComObject." );
                // We are sure that this instance of the processor will never be used again,
                // so we are safe to release it here
                Marshal.ReleaseComObject( processor );
            }

            // NB. Nulling the object WILL NOT do the trick as it did in Visual Basic 6.0.
            // Calling GC.Collect might SEEM to work under some conditions but does not
            // guarantee that a particular object will be freed (a stray reference).
            // Moreover, GC.Collect might be a very lengthy operation (if your managed heap
            // contains many objects) and calling it often might significantly degrade performance.
        }
开发者ID:DominatorCode,项目名称:FlexiCapture-Code-Snippets--C--,代码行数:45,代码来源:Frequently+asked+questions.cs

示例2: PrepareNewRecognizedDocument

        static IDocument PrepareNewRecognizedDocument( IEngine engine, out IFlexiCaptureProcessor processor )
        {
            // Create and configure an instance of FlexiCapture processor
            processor = engine.CreateFlexiCaptureProcessor();
            processor.AddDocumentDefinitionFile( SamplesFolder + "\\SampleProject\\Templates\\Invoice_eng.fcdot" );

            // Add images for a single multipage document
            processor.AddImageFile( SamplesFolder + "\\SampleImages\\Invoices_2.tif" );
            processor.AddImageFile( SamplesFolder + "\\SampleImages\\Invoices_3.tif" );

            // Recognize the document
            IDocument document = processor.RecognizeNextDocument();
            assert( document != null );
            assert( document.DocumentDefinition != null );
            assert( document.Pages.Count == 2 );

            return document;
        }
开发者ID:DominatorCode,项目名称:FlexiCapture-Code-Snippets--C--,代码行数:18,代码来源:Advanced+techniques.cs

示例3: CheckTrainedDocumentDefinition

        static void CheckTrainedDocumentDefinition( IEngine engine, IDocumentDefinition newDocumentDefinition, string rootFolder )
        {
            IFlexiCaptureProcessor processor = engine.CreateFlexiCaptureProcessor();
            processor.AddDocumentDefinition( newDocumentDefinition );
            processor.AddImageFile( rootFolder + "\\02.jpg" );
            processor.AddImageFile( rootFolder + "\\03.jpg" );

            IDocument document = processor.RecognizeNextDocument();
            assert( document.DocumentDefinition != null );
            assert( document.Pages.Count == 1 );
            assert( document.Sections[0].Children[0].Name == "ISBN" );
            assert( document.Sections[0].Children[0].Value.AsString == "0-517-59939-2" );

            document = processor.RecognizeNextDocument();
            assert( document.DocumentDefinition != null );
            assert( document.Pages.Count == 1 );
            assert( document.Sections[0].Children[0].Name == "ISBN" );
            assert( document.Sections[0].Children[0].Value.AsString == "0-8050-6176-2" );
        }
开发者ID:DominatorCode,项目名称:FlexiCapture-Code-Snippets--C--,代码行数:19,代码来源:Advanced+techniques.cs

示例4: Using_image_processing_tools_in_custom_preprocessing

        // USE CASE: Using image processing tools in custom preprocessing
        public static void Using_image_processing_tools_in_custom_preprocessing( IEngine engine )
        {
            trace( "Create and configure an instance of FlexiCapture processor..." );
            IFlexiCaptureProcessor processor = engine.CreateFlexiCaptureProcessor();

            processor.AddDocumentDefinitionFile( SamplesFolder + "\\SampleProject\\Templates\\Invoice_eng.fcdot" );

            trace( "Set up an image source with custom preprocessing..." );
            // Create and configure sample image source. ALL PREPROCESSING IS DONE IN THE IMAGE SOURCE
            // (see SampleImageSource class for details)
            CustomPreprocessingImageSource imageSource = new CustomPreprocessingImageSource( engine );
            imageSource.AddImageFile( SamplesFolder + "\\SampleImages\\Invoices_1.tif" );
            imageSource.AddImageFile( SamplesFolder + "\\SampleImages\\Invoices_2.tif" );
            imageSource.AddImageFile( SamplesFolder + "\\SampleImages\\Invoices_3.tif" );
            processor.SetCustomImageSource( imageSource );

            traceBegin( "Process the images..." );
            int count = 0;
            while( true ) {
                IDocument document = processor.RecognizeNextDocument();
                if( document == null ) {
                    IProcessingError error = processor.GetLastProcessingError();
                    assert( error == null ); // No errors are expected in this sample
                    break;
                } else {
                    // We expect that this will never happen in this sample
                    assert( document.DocumentDefinition != null );
                }
                processor.ExportDocumentEx( document, SamplesFolder + "\\FCEExport", "NextDocument_" + count, null );
                count++;
            }
            traceEnd( "OK" );

            trace( "Check the results..." );
            assert( count == 2 );
        }
开发者ID:DominatorCode,项目名称:FlexiCapture-Code-Snippets--C--,代码行数:37,代码来源:Advanced+techniques.cs

示例5: Creating_a_Document_Definition_from_a_FlexiLayout

        // USE CASE: Creating a Document Definition from a FlexiLayout (*.afl)
        public static void Creating_a_Document_Definition_from_a_FlexiLayout( IEngine engine )
        {
            trace( "Create a Document Definition from an *.afl file..." );
            string flexibleDescriptionFilePath = SamplesFolder + "\\SampleMisc\\Invoice_eng.afl";
            IDocumentDefinition newDefinition = engine.CreateDocumentDefinitionFromAFL(	flexibleDescriptionFilePath, "English"	);

            // You can save the new Document Definition to a file or use it from memory
            traceBegin("Use the Document Definition in FlexiCaptureProcessor...");
                IFlexiCaptureProcessor processor = engine.CreateFlexiCaptureProcessor();
                processor.AddDocumentDefinition( newDefinition );

                // Add images for a single document
                processor.AddImageFile( SamplesFolder + "\\SampleImages\\Invoices_1.tif" );

                // Recognize the document and check the result
                IDocument document = processor.RecognizeNextDocument();
                assert( document != null );
                assert( document.DocumentDefinition != null );
                assert( document.Pages.Count == 1 );

                // Export the result
                processor.ExportDocumentEx( document, SamplesFolder + "\\FCEExport", "Invoice", null );
            traceEnd( "OK" );
        }
开发者ID:DominatorCode,项目名称:FlexiCapture-Code-Snippets--C--,代码行数:25,代码来源:Advanced+techniques.cs

示例6: Creating_a_Document_Definition_from_an_XML_Form_Definition

        // USE CASE: Creating a Document Definition from an XML Form Definition
        public static void Creating_a_Document_Definition_from_an_XML_Form_Definition( IEngine engine )
        {
            trace("Create a Document Definition from an *.xfd file...");
            string formDescriptionFilePath = SamplesFolder + "\\SampleMisc\\Banking_eng.xfd";
            IDocumentDefinition newDefinition = engine.CreateDocumentDefinitionFromXFD(	formDescriptionFilePath, "English"	);

            // Modify the template as required. In this sample we need to loosen some constraints
            IPageAnalysisParams analysisParams = engine.CreatePageAnalysisParams();
            analysisParams.CopyFrom( newDefinition.PageAnalysisParams );
            analysisParams.MaxHorizontalShrinkPercent = 20;
            analysisParams.MaxVerticalShrinkPercent = 20;
            newDefinition.PageAnalysisParams = analysisParams;

            // You can save the new Document Definition to a file or use it from memory
            traceBegin("Use the Document Definition in FlexiCaptureProcessor...");
                IFlexiCaptureProcessor processor = engine.CreateFlexiCaptureProcessor();
                processor.AddDocumentDefinition( newDefinition );

                // Add images for a single multipage document
                processor.AddImageFile( SamplesFolder + "\\SampleImages\\Banking_1.tif" );
                processor.AddImageFile( SamplesFolder + "\\SampleImages\\Banking_2.tif" );
                processor.AddImageFile( SamplesFolder + "\\SampleImages\\Banking_3.tif" );

                // Recognize the document and check the result
                IDocument document = processor.RecognizeNextDocument();
                assert( document != null );
                assert( document.DocumentDefinition != null );
                assert( document.Pages.Count == 3 );

                // Export the result
                processor.ExportDocumentEx( document, SamplesFolder + "\\FCEExport", "Banking", null );
            traceEnd( "OK" );
        }
开发者ID:DominatorCode,项目名称:FlexiCapture-Code-Snippets--C--,代码行数:34,代码来源:Advanced+techniques.cs

示例7: Configuring_fields_for_better_recognition_results

        // USE CASE: Configuring fields for better recognition results
        public static void Configuring_fields_for_better_recognition_results( IEngine engine )
        {
            trace( "Create a Document Definition from a FlexiLayout..." );
            IDocumentDefinition newDefinition = engine.CreateDocumentDefinitionFromAFL( SamplesFolder + "\\SampleMisc\\Invoice_eng.afl", "English" );
            assert( newDefinition != null );

            trace( "Configure data types..." );
            setFieldValueType( newDefinition, "InvoiceDate", FieldValueTypeEnum.FVT_DateTime );
            setFieldValueType( newDefinition, "Quantity", FieldValueTypeEnum.FVT_Number );
            setFieldValueType( newDefinition, "UnitPrice", FieldValueTypeEnum.FVT_Currency );
            setFieldValueType( newDefinition, "Total", FieldValueTypeEnum.FVT_Currency );
            setFieldValueType( newDefinition, "TotalAmount", FieldValueTypeEnum.FVT_Currency );

            trace( "Configure recognition languages for text fields ..." );
            IFieldDefinition fieldDef = findFieldDef( newDefinition, "InvoiceNumber" );
            assert( fieldDef != null );
            ITextRecognitionParams textParams = fieldDef.RecognitionParams.AsTextParams();
            ILanguage newLanguage = textParams.CreateEmbeddedLanguageByDataType( FieldValueTypeEnum.FVT_DateTime );
            textParams.Language = newLanguage;

            newLanguage = textParams.CreateEmbeddedLanguage( textParams.Language.Type, textParams.Language );
            assert( newLanguage != textParams.Language );
            assert( newLanguage.LanguageCategory == LanguageCategoryEnum.LC_DataType );
            assert( newLanguage.DatatypeCategory == DatatypeCategoryEnum.TC_DateTime );
            textParams.Language = newLanguage;

            newLanguage = textParams.CreateEmbeddedLanguage( LanguageTypeEnum.LT_Group, null );
            newLanguage.AsGroupLanguage().Add( engine.PredefinedLanguages.FindLanguage( "English" ) );
            newLanguage.AsGroupLanguage().Add( engine.PredefinedLanguages.FindLanguage( "Russian" ) );
            textParams.Language = newLanguage;
            assert( textParams.Language.Type == LanguageTypeEnum.LT_Group );
            assert( textParams.Language.AsGroupLanguage().Count == 2 );
            assert( textParams.Language.AsGroupLanguage().Item( 0 ).InternalName == "English" );
            assert( textParams.Language.AsGroupLanguage().Item( 1 ).InternalName == "Russian" );

            newLanguage = textParams.CreateEmbeddedLanguage( LanguageTypeEnum.LT_Simple, null );
            newLanguage.AsSimpleLanguage().set_LetterSet( LanguageLetterSetEnum.LLS_Alphabet, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" );
            newLanguage.AsSimpleLanguage().RegularExpression = "[A-Z]{1-}";
            textParams.Language = newLanguage;
            assert( textParams.Language.AsSimpleLanguage().RegularExpression.Length > 0 );

            newLanguage = textParams.CreateEmbeddedLanguage( LanguageTypeEnum.LT_Simple, engine.PredefinedLanguages.FindLanguage( "English" ) );
            assert( newLanguage.AsSimpleLanguage().UsePredefinedDictionary == true );
            assert( newLanguage.AsSimpleLanguage().UseUserDefinedDictionary == false );
            assert( newLanguage.AsSimpleLanguage().UserDefinedDictionary == null );
            newLanguage.AsSimpleLanguage().UseUserDefinedDictionary = true;
            FCEngine.IDictionary dictionary = newLanguage.AsSimpleLanguage().UserDefinedDictionary;
            assert( dictionary != null );
            assert( dictionary.WordsCount == 0 );
            dictionary.AddWord( "ONE", 1 );
            dictionary.AddWord( "TWO", 1 );
            dictionary.AddWord( "THREE", 1 );
            assert( dictionary.WordsCount == 3 );
            IEnumDictionaryWords enumWords = dictionary.EnumWords();
            for( int i = 0; i < 10; i++ ) {
                int confidence = 0;
                string word = enumWords.Next( out confidence );
                if( confidence == 0 ) {
                    break;
                }
                trace( word );
            }
            textParams.Language = newLanguage;

            trace( "Check the Document Definition..." );
            assert( newDefinition.Check() == true );

            traceBegin("Use the Document Definition in FlexiCaptureProcessor...");
                IFlexiCaptureProcessor processor = engine.CreateFlexiCaptureProcessor();
                processor.AddDocumentDefinition( newDefinition );

                // Add images for a single document
                processor.AddImageFile( SamplesFolder + "\\SampleImages\\Invoices_1.tif" );

                // Recognize the document
                IDocument document = processor.RecognizeNextDocument();
                assert( document != null );
                assert( document.DocumentDefinition != null );
                assert( document.Pages.Count == 1 );

                processor.ExportDocumentEx( document, SamplesFolder + "\\FCEExport", "Invoice", null );
            traceEnd( "OK" );
        }
开发者ID:DominatorCode,项目名称:FlexiCapture-Code-Snippets--C--,代码行数:84,代码来源:Advanced+techniques.cs

示例8: Creating_a_compound_Document_Definition

        // USE CASE: Creating a compound Document Definition
        public static void Creating_a_compound_Document_Definition( IEngine engine )
        {
            trace( "Create an empty Document Definition in memory..." );
            IDocumentDefinition newDefinition = engine.CreateDocumentDefinition();
            assert( newDefinition != null );

            trace( "Set default language..." );
            ILanguage language = engine.PredefinedLanguages.FindLanguage( "English" );
            assert( language != null );
            newDefinition.DefaultLanguage = language;

            trace( "Create a new fixed section from an XFD file..." );
            newDefinition.DefaultTextType = TextTypeEnum.TT_Handprinted;
            ISectionDefinition newSection1 = newDefinition.Sections.AddNew( "Banking" );
            newSection1.LoadXFDDescription( SamplesFolder + "\\SampleMisc\\Banking_eng.xfd" );

            trace( "Create a new flexible section from an AFL file..." );
            newDefinition.DefaultTextType = TextTypeEnum.TT_Normal;
            ISectionDefinition newSection2 = newDefinition.Sections.AddNew( "Invoice" );
            newSection2.LoadFlexibleDescription( SamplesFolder + "\\SampleMisc\\Invoice_eng.afl" );

            // Modify the template as required. In this sample we need to loosen some constraints
            IPageAnalysisParams analysisParams = engine.CreatePageAnalysisParams();
            analysisParams.CopyFrom( newDefinition.PageAnalysisParams );
            analysisParams.MaxHorizontalShrinkPercent = 20;
            analysisParams.MaxVerticalShrinkPercent = 20;
            newDefinition.PageAnalysisParams = analysisParams;

            trace("Check the Document Definition...");
            assert( newDefinition.Check() == true );

            // You can save the new Document Definition to a file or use it from memory
            traceBegin("Use the Document Definition in FlexiCaptureProcessor...");
                IFlexiCaptureProcessor processor = engine.CreateFlexiCaptureProcessor();
                processor.AddDocumentDefinition( newDefinition );

                // Add images for a single multipage document
                processor.AddImageFile( SamplesFolder + "\\SampleImages\\Banking_1.tif" );
                processor.AddImageFile( SamplesFolder + "\\SampleImages\\Banking_2.tif" );
                processor.AddImageFile( SamplesFolder + "\\SampleImages\\Banking_3.tif" );
                processor.AddImageFile( SamplesFolder + "\\SampleImages\\Invoices_2.tif" );
                processor.AddImageFile( SamplesFolder + "\\SampleImages\\Invoices_3.tif" );

                // Recognize the document
                IDocument document = processor.RecognizeNextDocument();
                assert( document != null );
                assert( document.DocumentDefinition != null );
                assert( document.Pages.Count == 5 );

                processor.ExportDocumentEx( document, SamplesFolder + "\\FCEExport", "Mixed", null );
            traceEnd( "OK" );
        }
开发者ID:DominatorCode,项目名称:FlexiCapture-Code-Snippets--C--,代码行数:53,代码来源:Advanced+techniques.cs

示例9: Using_a_custom_image_source_with_FlexiCapture_processor

        // USE CASE: Using a custom image source with FlexiCapture processor
        public static void Using_a_custom_image_source_with_FlexiCapture_processor( IEngine engine )
        {
            trace( "Create an instance of FlexiCapture processor..." );
            IFlexiCaptureProcessor processor = engine.CreateFlexiCaptureProcessor();

            trace( "Add required Document Definitions..." );
            processor.AddDocumentDefinitionFile( SamplesFolder + "\\SampleProject\\Templates\\Invoice_eng.fcdot" );

            trace( "Set up a custom image source..." );
            // Create and configure sample image source (see SampleImageSource class for details)
            SampleImageSource imageSource = new SampleImageSource();
            // The sample image source will use these files by reference:
            imageSource.AddImageFileByRef( SamplesFolder + "\\SampleImages\\Invoices_1.tif" );
            imageSource.AddImageFileByRef( SamplesFolder + "\\SampleImages\\Invoices_2.tif" );
            imageSource.AddImageFileByRef( SamplesFolder + "\\SampleImages\\Invoices_3.tif" );
            // ... these files by value (files in memory):
            imageSource.AddImageFileByValue( SamplesFolder + "\\SampleImages\\Invoices_1.tif" );
            imageSource.AddImageFileByValue( SamplesFolder + "\\SampleImages\\Invoices_2.tif" );
            imageSource.AddImageFileByValue( SamplesFolder + "\\SampleImages\\Invoices_3.tif" );
            // Configure the processor to use the new image source
            processor.SetCustomImageSource( imageSource );

            traceBegin( "Run processing loop..." );
            int count = 0;
            while( true ) {
                trace( "Recognize next document..." );
                IDocument document = processor.RecognizeNextDocument();
                if( document == null ) {
                    IProcessingError error = processor.GetLastProcessingError();
                    if( error != null ) {
                        processError( error, processor, ErrorHandlingStrategy.LogAndContinue );
                        continue;
                    } else {
                        trace( "No more images" );
                        break;
                    }
                } else if( document.DocumentDefinition == null ) {
                    processNotMatched( document );
                }
                trace( "Export recognized document..." );
                processor.ExportDocumentEx( document, SamplesFolder + "\\FCEExport", "NextDocument_" + count, null );
                count++;
            }
            traceEnd( "OK" );

            trace( "Check the results..." );
            assert( count == 4 );
        }
开发者ID:DominatorCode,项目名称:FlexiCapture-Code-Snippets--C--,代码行数:49,代码来源:Using+FlexiCapture+technology+API.cs

示例10: Recognizing_a_sequence_of_image_files_using_FlexiCapture_processor

        // USE CASE: Recognizing a sequence of image files using FlexiCapture processor
        public static void Recognizing_a_sequence_of_image_files_using_FlexiCapture_processor( IEngine engine )
        {
            trace( "Create an instance of FlexiCapture processor..." );
            IFlexiCaptureProcessor processor = engine.CreateFlexiCaptureProcessor();

            trace( "Add required Document Definitions..." );
            processor.AddDocumentDefinitionFile( SamplesFolder + "\\SampleProject\\Templates\\Invoice_eng.fcdot" );

            trace( "Add the image files to recognize..." );
            processor.AddImageFile( SamplesFolder + "\\SampleImages\\Invoices_1.tif" );
            //processor.AddImageFile( SamplesFolder + "\\SampleImages\\Invoices_2.tif" );
            processor.AddImageFile( SamplesFolder + "\\SampleImages\\Invoices_3.tif" );

            traceBegin( "Run processing loop..." );
            int count = 0;
            while( true ) {
                trace( "Recognize next document..." );
                IDocument document = processor.RecognizeNextDocument();

                if( document == null ) {
                    IProcessingError error = processor.GetLastProcessingError();
                    if( error != null ) {
                        processError( error, processor, ErrorHandlingStrategy.LogAndContinue );
                        continue;
                    } else {
                        trace( "No more images" );
                        break;
                    }
                } else if( document.DocumentDefinition == null ) {
                    processNotMatched( document );
                }

                trace( "Export recognized document..." );
                processor.ExportDocumentEx( document, SamplesFolder + "\\FCEExport", "NextDocument_" + count, null );
                count++;
            }
            traceEnd( "OK" );

            trace( "Check the results..." );
            assert( count == 2 );
        }
开发者ID:DominatorCode,项目名称:FlexiCapture-Code-Snippets--C--,代码行数:42,代码来源:Using+FlexiCapture+technology+API.cs

示例11: Implementing_custom_storage

        // USE CASE: Implementing custom storage
        public static void Implementing_custom_storage( IEngine engine )
        {
            trace( "Prepare a sample document..." );
            IDocument document = PrepareNewRecognizedDocument( engine );

            // If an object supports custom storage, it implements ICustomStorage interface
            ICustomStorage customStorage = document as ICustomStorage;
            assert( customStorage != null );
            // NB. It is the same object but we see it through a different interface
            assert( customStorage == document );

            trace( "Save the document to a file..." );
            customStorage.SaveToFile( SamplesFolder + "\\FCEExport\\Document.mydoc" );

            trace( "Save the document to a stream..." );
            // The sample write stream is implemented as writing to a file (see SampleWriteStream for details)
            SampleWriteStream writeStream = new SampleWriteStream( SamplesFolder + "\\FCEExport\\Document.mystream" );
            try {
                customStorage.SaveToStream( writeStream );
            } finally {
                writeStream.Close();
            }

            IFlexiCaptureProcessor processor = engine.CreateFlexiCaptureProcessor();

            trace( "Load a document from file..." );
            IDocument newDocument = processor.CreateDocument();
            customStorage = newDocument as ICustomStorage;
            assert( customStorage != null );

            customStorage.LoadFromFile( SamplesFolder + "\\FCEExport\\Document.mydoc" );
            processor.ExportDocumentEx( newDocument, SamplesFolder + "\\FCEExport", "LoadedFromFile", null );

            trace( "Load a document from stream..." );
            newDocument = processor.CreateDocument();
            customStorage = newDocument as ICustomStorage;
            assert( customStorage != null );

            // The sample read stream is implemented as reading from a file (see SampleReadStream for details)
            SampleReadStream readStream = new SampleReadStream( SamplesFolder + "\\FCEExport\\Document.mystream" );
            customStorage.LoadFromStream( readStream );
            processor.ExportDocumentEx( newDocument, SamplesFolder + "\\FCEExport", "LoadedFromStream", null );

            traceEnd( "OK" );
        }
开发者ID:DominatorCode,项目名称:FlexiCapture-Code-Snippets--C--,代码行数:46,代码来源:Using+FlexiCapture+technology+API.cs

示例12: Implementing_custom_reference_manager

        // USE CASE: Implementing custom reference manager
        public static void Implementing_custom_reference_manager( IEngine engine )
        {
            trace( "Create an instance of FlexiCapture processor..." );
            IFlexiCaptureProcessor processor = engine.CreateFlexiCaptureProcessor();

            trace( "Configure the processor to use a custom reference manager..." );
            // The sample reference manager can resolve "protocol:\\" references (see SampleReferenceManager for details)
            processor.SetReferenceManager( new SampleReferenceManager() );
            // Now we can pass references starting with "protocol:\\" and they will be correctly resolved:
            processor.AddDocumentDefinitionFile( "protocol:\\SampleProject\\Templates\\Invoice_eng.fcdot" );

            trace( "Add image files..." );
            processor.AddImageFile( "protocol:\\SampleImages\\Invoices_2.tif" );
            processor.AddImageFile( "protocol:\\SampleImages\\Invoices_3.tif" );

            trace( "Recognize and export..." );
            IDocument document = processor.RecognizeNextDocument();
            assert( document != null );
            assert( document.Pages.Count == 2 );
            processor.ExportDocumentEx( document, SamplesFolder + "\\FCEExport", "ReferenceManager", null );

            traceEnd( "OK" );
        }
开发者ID:DominatorCode,项目名称:FlexiCapture-Code-Snippets--C--,代码行数:24,代码来源:Using+FlexiCapture+technology+API.cs

示例13: Handling_errors_in_the_image_queue

        // USE CASE: Handling errors in the image queue
        public static void Handling_errors_in_the_image_queue( IEngine engine )
        {
            trace( "Create and configure an instance of FlexiCapture processor..." );
            IFlexiCaptureProcessor processor = engine.CreateFlexiCaptureProcessor();
            processor.AddDocumentDefinitionFile( SamplesFolder + "\\SampleProject\\Templates\\Invoice_eng.fcdot" );

            trace( "Fill the image queue so that errors should occur..." );
            processor.AddImageFile( SamplesFolder + "\\SampleImages\\Invoices_1.tif" );
            // ... this file does not exist:
            processor.AddImageFile( SamplesFolder + "\\SampleImages\\DOESNOTEXIST.tif" );
            processor.AddImageFile( SamplesFolder + "\\SampleImages\\Invoices_2.tif" );
            processor.AddImageFile( SamplesFolder + "\\SampleImages\\Invoices_3.tif" );
            // ... this file exists but will not be accessible:
            string accessDeniedPath = SamplesFolder + "\\SampleImages\\ACCESSDENIED.tif";
            FileStream accessDeniedStream = File.Open( accessDeniedPath, FileMode.OpenOrCreate, FileAccess.Write );
            processor.AddImageFile( SamplesFolder + "\\SampleImages\\ACCESSDENIED.tif" );
            processor.AddImageFile( SamplesFolder + "\\SampleImages\\Invoices_1.tif" );

            traceBegin( "Run processing loop..." );
            int count = 0;
            while( true ) {
                trace( "Recognize next document..." );
                IDocument document = processor.RecognizeNextDocument();

                if( document == null ) {
                    IProcessingError error = processor.GetLastProcessingError();
                    if( error != null ) {
                        // Try changing the error handling strategy below (see ErrorHandlingStrategy enum).
                        // See processError implementation for details
                        processError( error, processor, ErrorHandlingStrategy.LogAndContinue );
                        continue;
                    } else {
                        trace( "No more images" );
                        break;
                    }
                } else if( document.DocumentDefinition == null ) {
                    processNotMatched( document );
                }

                trace( "Export recognized document..." );
                processor.ExportDocumentEx( document, SamplesFolder + "\\FCEExport", "NextDocument_" + count, null );
                count++;
            }
            traceEnd( "OK" );

            accessDeniedStream.Close();
            File.Delete( accessDeniedPath );

            trace( "Check the results..." );
            assert( count == 3 );
        }
开发者ID:DominatorCode,项目名称:FlexiCapture-Code-Snippets--C--,代码行数:52,代码来源:Using+FlexiCapture+technology+API.cs


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