OCR reading using C#

2019-09-19 08:34发布

问题:

I have a project which is to read character in a captured image but I'm stuck at the button which is to scan image. I ended up tesseract dll in c#, but I don't know how can I code it. I'm a newbie to this programming.

 private void Browse_Click(object sender, EventArgs e)
    {
        //FileInfo fi = new FileInfo(string.Format(@"C:\Documents and Settings\JOrce0201610\My Documents\Visual Studio 2005\Projects\OCR Reader\{0}", imageName));
        OpenFileDialog fi = new OpenFileDialog();
        fi.InitialDirectory = @"C:\\Documents and Settings\JOrce0201610\My Documents\Visual Studio 2005\Projects\OCR Reader\Card";
        fi.Filter = "BMP Image|*.bmp";
        fi.FilterIndex = 2;
        fi.RestoreDirectory = true;
        if (fi.ShowDialog() == DialogResult.OK)
        {
            //image file path
            textBox1.Text = fi.FileName;
            //display image in picture box
            pictureBox1.Image = new Bitmap(fi.FileName);
        }
    }
    private void Scan_Click(object sender, EventArgs e)
    {
        Bitmap temp = source.Clone() as Bitmap; //Clone image to keep original image

        FiltersSequence seq = new FiltersSequence();
        seq.Add(Grayscale.CommonAlgorithms.BT709);  //First add  GrayScaling filter
        seq.Add(new OtsuThreshold()); //Then add binarization(thresholding) filter
        temp = seq.Apply(source); // Apply filters on source image

回答1:

If you are a 'newbie' to programming, OCR is not the best place to start. The best I can suggest is that you use a webservice or existing library that can do this for you.

Microsoft has project Hawaii, Hawaii has an OCR service which is quite easy to use.



标签: c# ocr tesseract