예제 #1
0
        private void IterateFullPage(ResultIterator iter, ref List <TextLine> _textLines)
        {
            int left, top, right, bottom;


            StringBuilder     ss    = new StringBuilder(string.Empty);
            PageIteratorLevel level = PageIteratorLevel.RIL_TEXTLINE;
            string            t;

            do
            {
                TextLine l = new TextLine();
                t = iter.GetUTF8Text(level);

                ss.Append(t);
                iter.BoundingBox(level, out left, out top, out right, out bottom);

                l.Bounds = new Rectangle(left, top, right - left, bottom - top);

                l.Text = t ?? string.Empty;


                level   = PageIteratorLevel.RIL_WORD;
                l.Words = new List <Word>();
                do
                {
                    Word w = new Word();
                    iter.BoundingBox(level, out left, out top, out right, out bottom);
                    w.Text       = iter.GetUTF8Text(level);
                    w.Confidence = iter.Confidence(level);
                    w.Bounds     = new Rectangle(left, top, right - left, bottom - top);
                    l.Words.Add(w);
                    if (iter.IsAtFinalElement(PageIteratorLevel.RIL_TEXTLINE, PageIteratorLevel.RIL_WORD))
                    {
                        break;
                    }
                } while (iter.Next(level));
                level = PageIteratorLevel.RIL_TEXTLINE;

                ss.Append(System.Environment.NewLine);
                _textLines.Add(l);
            } while (iter.Next(level));



            text = ss.ToString();
        }