Ejemplo n.º 1
0
        private RecognitionStatistics computeStatistics(FREngine.IFRDocument frDocument)
        {
            RecognitionStatistics result = new RecognitionStatistics();

            result.RecognizedText = new List <RecognizedText>();

            CustomFile file = new CustomFile();


            for (int pageIndex = 0; pageIndex < frDocument.Pages.Count; pageIndex++)
            {
                FREngine.IFRPage frPage = frDocument.Pages[pageIndex];
                FREngine.ILayout layout = frPage.Layout;
                int blocksCount         = layout.Blocks.Count;
                for (int blockIndex = 0; blockIndex < blocksCount; blockIndex++)
                {
                    FREngine.IBlock block = layout.Blocks[blockIndex];

                    result += computeStatisticsForBlock(pageIndex, block);
                }



                result.RecognizedText.Add(new RecognizedText(frPage, pageIndex));

                frPage.Flush(false);
            }
            return(result);
        }
Ejemplo n.º 2
0
        private int[] splitImage(FREngine.IFRDocument frDoc, FREngine.IPageProcessingParams ppp, ProcessingSettings settings)
        {
            FREngine.PageSplittingParams pageSplittingParams = engine.CreatePageSplittingParams();
            pageSplittingParams.SplitType = FREngine.PageSplitTypeEnum.PST_None;
            if (settings.SplitPages)
            {
                pageSplittingParams.SplitType = FREngine.PageSplitTypeEnum.PST_DoublePageSplit;
            }
            else if (settings.SplitBusinessCards)
            {
                pageSplittingParams.SplitType = FREngine.PageSplitTypeEnum.PST_BusinessCardSplit;
            }
            else
            {
                int[] emptyPageIndices = new int[1];
                emptyPageIndices[0] = 0;
                return(emptyPageIndices);
            }
            if (settings.CorrectOrientationMode != ProcessingSettings.OrientationCorrectionMode.None)
            {
                ppp.PagePreprocessingParams.CorrectOrientation = true;
            }

            engine.MultiProcessingParams.MultiProcessingMode = FREngine.MultiProcessingModeEnum.MPM_Sequential;
            FREngine.SplitRegions splitRegions = frDoc.SplitPages(null, pageSplittingParams, ppp.ObjectsExtractionParams);
            engine.MultiProcessingParams.MultiProcessingMode = FREngine.MultiProcessingModeEnum.MPM_Auto;

            int[] sourcePageIndices = new int[frDoc.Pages.Count];
            for (int pageIndex = 0; pageIndex < sourcePageIndices.Length; pageIndex++)
            {
                sourcePageIndices[pageIndex] = -1;
            }

            foreach (FREngine.SplitRegion item in splitRegions)
            {
                FREngine.IFRPage frPage = frDoc.Pages[item.CurrentPageIndex];
                sourcePageIndices[item.CurrentPageIndex] = item.SourcePageIndex;

                if (settings.CropImage)
                {
                    frPage.ImageDocument.CropImage();
                }

                if (settings.CorrectDistortions)
                {
                    frPage.CorrectGeometricalDistortions(ppp.ObjectsExtractionParams);
                }

                if (settings.DeskewImage)
                {
                    frPage.ImageDocument.CorrectSkew(correctSkewFlags);
                }

                frPage.Flush(true);
            }

            for (int pageIndex = 0; pageIndex < sourcePageIndices.Length; pageIndex++)
            {
                if (sourcePageIndices[pageIndex] == -1)
                {
                    sourcePageIndices[pageIndex] = pageIndex == 0 ? 0 : sourcePageIndices[pageIndex - 1] + 1;
                }
            }
            return(sourcePageIndices);
        }