I tried using MatchTemplate() to match numbers in image. For example, the numbers are [0985-977-735] in image. And got the results as following:(number, location) [(0, 1), (3, 103), (5, 33), (5, 116), (7, 62), (7, 73), (7, 85), (8, 21), (9, 11), (9, 53)]
But in most situations, the accuracy is very low.
[0983-945-180]: [(0, 113), (1, 93), (3, 31), (4, 62), (5, 74), (8, 103), (9, 11), (9, 53)] the first zero and eight can't be recognized.
[0932-509-607] [(0, 103), (2, 31), (3, 21), (5, 54), (6, 92), (7, 113), (9, 72)] the first, second zero and first nine can't be recognized.
[0911-873-752] [(0, 1), (1, 22), (1, 33), (2, 113), (3, 72), (5, 105), (7, 92), (8, 52), (9, 11)] the first seven can't be recognized.
part of the code as following:
import cv
for i in range(10):
template_im = cv.LoadImage(template_file, cv.CV_LOAD_IMAGE_GRAYSCALE)
width = original_im.width - template_im.width + 1
height = original_im.height - template_im.height +1
result_image = cv.CreateImage((width, height), cv.IPL_DEPTH_32F, 1)
cv.Zero(result_image)
cv.MatchTemplate(original_im, template_im, result_image, cv.CV_TM_CCOEFF_NORMED)
(_, R, _, max_loc) = cv.MinMaxLoc(result_image)
if R < 0.90:
pass
else:
phone_number_location.append((i, max_loc[0]))
...
...