// USE CASE: Using a configured FlexiCapture project to recognize image files
        public static void Using_a_configured_FlexiCapture_project_to_recognize_image_files(IEngine engine)
        {
            trace("Open the sample project...");
            IProject project = engine.OpenProject(SamplesFolder + "\\SampleProject\\Invoices_eng.fcproj");

            try {
                trace("Add a new batch...");
                IBatch batch = project.Batches.AddNew("TestBatch");

                trace("Open the batch...");
                batch.Open();

                try {
                    trace("Add image files to the batch...");
                    batch.AddImage(SamplesFolder + "\\SampleImages\\Invoices_1.tif");
                    batch.AddImage(SamplesFolder + "\\SampleImages\\Invoices_2.tif");
                    batch.AddImage(SamplesFolder + "\\SampleImages\\Invoices_3.tif");

                    trace("Recognize all images in the batch...");
                    batch.Recognize(null, RecognitionModeEnum.RM_ReRecognizeMinimal, null);

                    trace("Export the results...");
                    batch.Export(null, null);

                    trace("Close and delete the batch...");
                } finally {
                    batch.Close();                     // Before the batch could be deleted, it has to be closed
                    project.Batches.DeleteAll();
                }

                trace("Close the project...");
            } finally {
                project.Close();
            }
        }
Beispiel #2
0
        // USE CASE: Using a configured FlexiCapture project to recognize image files
        public static void Using_a_configured_FlexiCapture_project_to_recognize_image_files(IEngine engine)
        {
            trace("Open the sample project...");
            IProject project = engine.OpenProject("D:\\Users\\seral\\Desktop\\SampleImages\\SampleProject\\DocScan1CProject\\DocScan1CProject.fcproj");

            try {
                trace("Add a new batch...");
                IBatch batch = project.Batches.AddNew("DocScan1C");

                trace("Open the batch...");
                batch.Open();

                try {
                    IStringsCollection filePaths = engine.CreateStringsCollection();
                    filePaths.Add(SamplesFolder + "1134.pdf");
                    filePaths.Add(SamplesFolder + "Scan_07_θη_06.bmp");
                    //filePaths.Add(SamplesFolder + "Scan_02_θη_06.jpg");
                    // filePaths.Add(SamplesFolder + "Scan_08_θη_06.jpg");*/

                    IStringsCollection badFiles = engine.CreateStringsCollection();;
                    ILongsCollection   docIds   = engine.CreateLongsCollection();

                    trace("Add image files to the batch...");
                    batch.AddImages(filePaths, -1, null, null, badFiles, docIds);

                    trace("Recognize all images in the batch...");
                    batch.Recognize(null, RecognitionModeEnum.RM_ReRecognizeMinimal, null);

                    trace("Export the results...");

                    IExportParams exportParams = engine.CreateExportParams(ExportDestinationTypeEnum.EDT_File);
                    exportParams.IgnoreRuleErrors                 = true;
                    exportParams.FileExportParams.RootPath        = "D:\\Users\\seral\\Desktop\\FCEExport";
                    exportParams.FileExportParams.FileFormat      = FileExportFormatEnum.FEF_XML;
                    exportParams.FileExportParams.FileNamePattern = "<DocumentDefinition>";
                    exportParams.FileExportParams.CreateSeparateFilesForRepeatableItems = true;
                    exportParams.FileExportParams.FileOverwriteRule = FileOverwriteRuleEnum.FOR_Rename;

                    batch.Export(null, exportParams);
                    trace("Close and delete the batch...");
                } finally {
                    batch.Close();                     // Before the batch could be deleted, it has to be closed
                    project.Batches.DeleteAll();
                }

                trace("Close the project...");
            } finally {
                project.Close();
            }
        }
Beispiel #3
0
        // USE CASE: Using collection events
        public static void Using_collection_events(IEngine engine)
        {
            // Collection events are mainly intended for use in creating UI views for FlexiCapture Engine objects.
            // By listening to collection events listeners can duly react to changes in the model.

            trace("Open the project...");
            IProject project = engine.OpenProject(SamplesFolder + "\\SampleProject\\Invoices_eng.fcproj");

            // Start listening to project.Batches events. In a real-life usage scenario the listener
            // would be some kind of a visual control, showing the list of batches and redrawing
            // itself when the collection changes
            SampleCollectionEventsSink batchesEvents = new SampleCollectionEventsSink(project.Batches, "project.Batches");

            try {
                trace("Add a new batch...");
                IBatch batch = project.Batches.AddNew("TestBatch");

                trace("Open the new batch...");
                batch.Open();

                // Start listening to batch.Documents events. In a real-life usage scenario the listener
                // would be some kind of a visual control, showing the list of documents and redrawing
                // itself when the collection changes
                SampleCollectionEventsSink documentsEvents = new SampleCollectionEventsSink(batch.Documents, "batch.Documents");

                try {
                    trace("Add the image files to the batch...");
                    batch.AddImage(SamplesFolder + "\\SampleImages\\Invoices_1.tif");
                    batch.AddImage(SamplesFolder + "\\SampleImages\\Invoices_2.tif");
                    batch.AddImage(SamplesFolder + "\\SampleImages\\Invoices_3.tif");

                    trace("Recognize the batch...");
                    batch.Recognize(null, RecognitionModeEnum.RM_ReRecognizeMinimal, null);

                    trace("Export the results...");
                    batch.Export(null, null);

                    trace("Close and delete the batch...");
                } finally {
                    documentsEvents.Dispose();
                    batch.Close();
                    project.Batches.DeleteAll();
                }

                trace("Close the project...");
            } finally {
                batchesEvents.Dispose();
                project.Close();
            }
        }
Beispiel #4
0
        // USE CASE: Using batch processing events
        public static void Using_batch_processing_events(IEngine engine)
        {
            trace("Open a project...");
            IProject project = engine.OpenProject(SamplesFolder + "\\SampleProject\\Invoices_eng.fcproj");

            try {
                trace("Add a new batch...");
                IBatch batch = project.Batches.AddNew("TestBatch");

                trace("Open the new batch...");
                batch.Open();

                // Here we create an events sink which will capture batch processing events and
                // show progress and tracing messages in the status bar. This will also make UI
                // more responsive to user input. See definition of the sink class for details
                trace("Start listening to batch processing events...");
                SampleBatchEventsSink eventsSink = new SampleBatchEventsSink(batch);

                try {
                    trace("Add the image files to the batch...");
                    batch.AddImage(SamplesFolder + "\\SampleImages\\Invoices_1.tif");
                    batch.AddImage(SamplesFolder + "\\SampleImages\\Invoices_2.tif");
                    batch.AddImage(SamplesFolder + "\\SampleImages\\Invoices_3.tif");

                    trace("Recognize the batch...");
                    batch.Recognize(null, RecognitionModeEnum.RM_ReRecognizeMinimal, null);

                    trace("Export the results...");
                    batch.Export(null, null);

                    trace("Close and delete the batch...");
                } finally {
                    eventsSink.Dispose();
                    batch.Close();
                    project.Batches.DeleteAll();
                }

                trace("Close the project...");
            } finally {
                project.Close();
            }
        }