简体   繁体   中英

Detecting Text in an image

I am using AForge.NET library for image processing. Using this library I am able detect basic shapes within an image. How can I detect the text within an image using the AForge.NET library?

You will need to use Optical Character Recognition (OCR). One link I found on using it with AForge can be visited here . Some code from the link:

// "K" letter, but a little bit noised
float[] pattern = new float [] {
        0.5f, -0.5f, -0.5f,  0.5f,  0.5f,
        0.5f, -0.5f,  0.5f, -0.5f,  0.5f,
        0.5f,  0.5f, -0.5f, -0.5f, -0.5f,
        0.5f, -0.5f,  0.5f, -0.5f, -0.5f,
        0.5f, -0.5f, -0.5f,  0.5f, -0.5f,
        0.3f, -0.5f, -0.5f,  0.5f,  0.5f};

// get network's output
float[] output = neuralNet.Compute(pattern);

int i, n, maxIndex = 0;

// find the maximum from output
float max = output[0];
for (i = 1, n = output.Length; i < n; i++)
{
    if (output[i] > max)
    {
        max = output1[i];
        maxIndex = i;
    }
}

//
System.Diagnostics.Debug.WriteLine(
  "network thinks it is - " + (char)((int) 'A' + maxIndex));

The only other way I can think of doing it, is using Tessaract-OCR which can read a wide variety of image formats and convert them to text in over 40 languages. There are also many other ways of doing it out there, including using Microsoft Office , or Emgu cv .

There's one more link which might work. It detects playing cards in AForge, and while doing so reads the numbers or J, Q, and K in the corner. You may have seen it already .

Use Microsoft Cognitive Services - Computer Vision API

Optical Character Recognition (OCR) detects text in an image and extracts the recognized words into a machine-readable character stream

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM