Tharindu Senanayake
Tharindu Senanayake

Reputation: 285

Recognize Text in images using Canny Edge detection in Opencv

I'm trying to extract text from colored background images. One approach that I'm trying is edge detection. Using that I convert the original image to a image that I can work with. This will eliminate all the color in the image leaving only the edges.

I use this code to get the edged Image

import cv2
import numpy as np
from matplotlib import pyplot as plt

img = cv2.imread('messi5.jpg',0)
edges = cv2.Canny(img,100,200)

My problem is after I get these images how can I track the Letters in those images? Any help would be great. Thank you guys

These are the original and edge detected Images

Original Image

enter image description here

Edge Detected Image

enter image description here

Upvotes: 0

Views: 9756

Answers (2)

user1196549
user1196549

Reputation:

Using edge detection on this image is premature, because the edges of the character will get polluted by the edges of the background.

Here is what you can get by selecting the pixels close to white:

enter image description here

Interestingly, many people who post about similar problems believe edge detection to be the panacea. In my opinion it is quite often a waste and region segmentation is much more appropriate.

Upvotes: 4

BHawk
BHawk

Reputation: 2462

You are at the beginning of a very long process involving concepts of computer vision and machine learning. There is too much to explain in a simple, concise answer here. However, there are a lot of good resources for doing this online (see below):

python: Simple Digit Recognition OCR in OpenCV-Python

c++: https://www.mkompf.com/cplus/emeocv.html

Upvotes: 1

Related Questions