// 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);
        }