コード例 #1
0
        public IEnumerable <OcrResult> ProcessOcrResult(BitmapWithOcrMetaInfo image)
        {
            NumberOfAwaiters += 1;
            engineLock.WaitOne();

            Thread.CurrentThread.Priority = ThreadPriority.Highest;

            IEnumerable <OcrResult> outResults = null;

            using (var page = Engine.Process(image.BitmapAsBytes.ToBitmap(), PageSegMode.SingleBlock))
            {
                var rawText = OcrUtils.RemoveOcrArtifacts(page.GetHOCRText(0, false));

                var ocrWords = OcrUtils
                               .GetWords(rawText, image.OcrBoundingBox);

                outResults = ocrWords
                             .Select(x => new OcrResult()
                {
                    ContourOffset = image.OcrBoundingBox,
                    BoundingBox   = x.Key,
                    Result        = new string[] { x.Value }
                });
            }

            Thread.CurrentThread.Priority = ThreadPriority.Normal;

            engineLock.Release();
            NumberOfAwaiters -= 1;

            return(outResults);
        }
コード例 #2
0
 public IEnumerable <OcrResult> PerformOcr(BitmapWithOcrMetaInfo image)
 {
     return(EngineWithLowestAwaiters.ProcessOcrResult(image));
 }