Beispiel #1
0
        public string OcrImage(string img)
        {
            string        res  = String.Empty;
            List <string> wrds = new List <string>();

            try
            {
                if (File.Exists(img))
                {
                    using (Image <Bgr, byte> i = new Image <Bgr, byte>(img))
                    {
                        if (OcrEngine != null)
                        {
                            OcrEngine.Recognize(i);
                            res = OcrEngine.GetText().TrimEnd();

                            wrds.AddRange(res.Split(new string[] { " ", "\r", "\n" },
                                                    StringSplitOptions.RemoveEmptyEntries).ToList());

                            this.Words = wrds?.ToArray();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            return(res);
        }