private string ProcessImage(Bitmap img)
        {
            IOcrProcessor processor = new DtkOcrProcessor();

            try
            {
                return processor.ReadText(img);
            }
            catch (Exception ex)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
Beispiel #2
0
        private void OcrProcessImage()
        {
            try
            {
                if (_theImage != null)
                {
                    pictureBox1.SuspendLayout();
                    pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                    pictureBox1.Image = _theImage;
                    pictureBox1.ResumeLayout();

                    const string language = "eng";

                    IOcrProcessor processor = new DtkOcrProcessor();

                    using (var bmp = _theImage)
                    {
                        var result = processor.ReadText(_theImage);
                        if (string.IsNullOrEmpty(result))
                        {
                            ResultsTextBox.Text = "Failed to read plate.";
                        }
                        else
                        {
                            ResultsTextBox.Text = "";
                            var sb = new StringBuilder();
                            string text = result;
                            sb.AppendLine("Text:");
                            sb.AppendLine("*****************************");
                            sb.AppendLine(text);
                            sb.AppendLine("*****************************");
                            ResultsTextBox.Text = sb.ToString();
                        }
                    }

                }
                else
                {
                    MessageBox.Show(this, "Please select an image");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.ToString());
            }
        }