Priyank Thakkar
Priyank Thakkar

Reputation: 4852

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?

Upvotes: 3

Views: 12491

Answers (2)

Magnus Ahlin
Magnus Ahlin

Reputation: 655

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

Upvotes: 0

SuperPrograman
SuperPrograman

Reputation: 1822

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.

Upvotes: 2

Related Questions