Ejemplo n.º 1
0
        /// <summary>
        /// Detect all the characters in the image.
        /// </summary>
        /// <returns>All the characters in the image</returns>
        public Character[] GetCharacters()
        {
            using (VectorOfByte textSeq = new VectorOfByte())
                using (VectorOfTesseractResult results = new VectorOfTesseractResult())
                {
                    OcrInvoke.TessBaseAPIExtractResult(_ptr, textSeq, results);

                    byte[]            bytes = textSeq.ToArray();
                    TesseractResult[] trs   = results.ToArray();

                    Character[] res = new Character[trs.Length];
                    int         idx = 0;
                    for (int i = 0; i < trs.Length; i++)
                    {
                        TesseractResult tr = trs[i];
                        res[i].Text = _utf8.GetString(bytes, idx, tr.Length).Replace("\n", Environment.NewLine);

                        idx        += tr.Length;
                        res[i].Cost = tr.Cost;
                        if (tr.Cost == 0)
                        {
                            res[i].Region = Rectangle.Empty;
                        }
                        else
                        {
                            res[i].Region = tr.Region;
                        }
                    }
                    return(res);
                }
        }
 public DebuggerProxy(VectorOfTesseractResult v)
 {
     _v = v;
 }
 /// <summary>
 /// Push multiple values from the other vector into this vector
 /// </summary>
 /// <param name="other">The other vector, from which the values will be pushed to the current vector</param>
 public void Push(VectorOfTesseractResult other)
 {
     VectorOfTesseractResultPushVector(_ptr, other);
 }