Exemplo n.º 1
0
        private void _annAutomationObjects_ItemRemoved(object sender, AnnObjectCollectionEventArgs e)
        {
            // Check if we are updating the zones, no need for this
            if (_ignoreAddRemove)
            {
                return;
            }
            // User deleted the annotation object, delete the corresponding zone
            ZoneAnnotationObject zoneObject = e.Object as ZoneAnnotationObject;

            if (zoneObject != null)
            {
                if (_setSelect)
                {
                    InteractiveMode = ViewerControlInteractiveMode.SelectMode;
                    return;
                }
                _setSelect = true;
                int index = zoneObject.ZoneIndex;
                _ocrPage.Zones.RemoveAt(index);

                // Reset all the zones
                for (int i = 0; i < _annAutomation.Container.Children.Count; i++)
                {
                    zoneObject = _annAutomation.Container.Children[i] as ZoneAnnotationObject;
                    zoneObject.SetZone(_ocrPage, i, _showZonesToolStripButton.Checked, _showZoneNameToolStripButton.Checked);
                }

                // We should mark the page as unrecognized since we updated its zones
                _ocrPage.Unrecognize();
                // Update the thumbnail(s)
                DoAction("RefreshPagesControl", false);
            }
        }
Exemplo n.º 2
0
        private IOcrPage DoublePass(RasterImage image)
        {
            //first pass with default settings
            IOcrPage page = _ocrEngine.CreatePage(image.Clone(), OcrImageSharingMode.AutoDispose);

            page.Recognize(null);

            //second pass with mobile image processing set to true
            _ocrEngine.SettingManager.SetBooleanValue("Recognition.Preprocess.MobileImagePreprocess", true);
            IOcrPage mobilePage = _ocrEngine.CreatePage(image.Clone(), OcrImageSharingMode.AutoDispose);

            mobilePage.Recognize(null);

            //get the confidence of both pages
            PageResults firstPassResults  = GetPageConfidence(page);
            PageResults secondPassResults = GetPageConfidence(mobilePage);

            double confidenceDif = firstPassResults.Confidence - secondPassResults.Confidence;

            IOcrPage    highestConfidence;
            PageResults pageResultsHighest;

            if (confidenceDif > 2)
            {
                highestConfidence  = page;
                pageResultsHighest = firstPassResults;
            }
            else
            {
                highestConfidence  = mobilePage;
                pageResultsHighest = secondPassResults;
            }

            if (pageResultsHighest.TotalWords < 20)
            {
                IOcrPage thirdPass = highestConfidence.Copy();
                thirdPass.Unrecognize();
                OcrZone singleZone = new OcrZone()
                {
                    Bounds = new LeadRect(0, 0, image.Width, image.Height)
                };
                thirdPass.Zones.Add(singleZone);
                thirdPass.Recognize(null);
                PageResults thirdResults        = GetPageConfidence(thirdPass);
                double      confidencetDifThird = thirdResults.Confidence - pageResultsHighest.Confidence;
                if (confidenceDif > 5)
                {
                    highestConfidence  = thirdPass;
                    pageResultsHighest = thirdResults;
                }
            }

            return(highestConfidence);
        }