private string DetermineDocumentType(string projectId, string imageFile, string classifierPath)
        {
            Console.WriteLine("Determine Document Type is processing ...");
            if (engine == null)
            {
                engine = LoadEngine(projectId);
            }
            if (processor == null)
            {
                processor = engine.CreateFlexiCaptureProcessor();
                processor.AddClassificationTreeFile(classifierPath);
                Console.WriteLine("Classifier template is added ...");
            }
            else
            {
                processor.ResetProcessing();
                Console.WriteLine("Processor is reseted");
            }
            processor.AddImageFile(@imageFile);
            var result = processor.ClassifyNextPage();

            if (result != null && result.PageType == PageTypeEnum.PT_MeetsDocumentDefinition)
            {
                var names = result.GetClassNames();
                Console.WriteLine("Determine Document Type is completed");
                return(names.Item(0));
            }


            Console.WriteLine("Determine Document Type is not completed");
            return("");
        }
Beispiel #2
0
        public static Tuple <Dictionary <string, object>, List <object> > GetData(string imgPath)
        {
            if (engine == null)
            {
                engine = loadEngine();
            }
            if (processor == null)
            {
                processor = engine.CreateFlexiCaptureProcessor();
                processor.AddDocumentDefinitionFile("C:\\ProgramData\\ABBYY\\SDK\\11\\FlexiCapture Engine\\Samples\\SampleMisc\\Invoice.fcdot");
            }
            else
            {
                processor.ResetProcessing();
            }
            processor.AddImageFile(imgPath);
            IDocument document = processor.RecognizeNextDocument();

            if (document != null && document.DocumentDefinition != null)
            {
                return(ReadDocData(document));
            }
            return(null);
        }
        static void processError( IProcessingError error, IFlexiCaptureProcessor processor, ErrorHandlingStrategy strategy )
        {
            assert( error != null );

            // You can store the problematic image for later analysis
            if( error.ImageFile() != null ) {
                string imageReference = error.ImageFile().GetFileReference();
            }

            // And use different strategies to handle the error
            switch( strategy ) {
                // 1) Log the error and continue
                case ErrorHandlingStrategy.LogAndContinue:
                    trace( "Processing error: " + error.MessageText() );
                    return;
                // 2) Retry
                case ErrorHandlingStrategy.LogAndRetry:
                    trace( "Processing error: " + error.MessageText() );
                    // Resume processing from the position where error occurred
                    processor.ResumeProcessing( true );
                    return;
                // 3) Break processing
                case ErrorHandlingStrategy.ThrowException:
                    // This will reset the processing state (image queue, error condition, etc.) but keep
                    // the processing configuration (loaded templates and processing params). You can omit this
                    // call if you do not plan to reuse the processor instance or reset the processor elsewhere
                    processor.ResetProcessing();
                    throw new Exception( error.MessageText() );
            }
        }