我嘗試使用MatchTemplate()來匹配圖像中的數字。例如,圖片中的數字是[0985-977-735]。 (0,1),(3,103),(5,33),(5,116),(7,62),(7,73),(5),(7),(7),(7),(7) ,(7,85),(8,21),(9,11),(9,53)]如何提高OpenCV模板匹配的準確性
但是在大多數情況下,準確度非常低。 (0,113),(1,93),(3,31),(4,62),(5,74),(8,103),(3),(3),(4),(6), (9,11),(9,53)] 第一個零和八個不能被識別。 (0,103),(2,31),(3,21),(5,54),(6,92),(7,113),(7,113),(7,114), 9,72)] 第一個,第二個零和第九個不能被識別。 (1,102),(1,33),(2,113),(3,72),(5,105),(5,105) 7,92),(8,52),(9,11)] 前七位無法識別。代碼
部分如下:
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]))
...
...
你可以發佈你正在處理的圖像樣本嗎? – sinelaw 2012-04-23 15:55:34
如果你正在尋找一個數字OCR,你可以在這裏看到一個簡單的實現使用OpenCV-Python.http://stackoverflow.com/questions/9413216/simple-digit-recognition-ocr-in-opencv-python/9620295# 9620295 – 2012-04-23 17:17:01
可能重複[在Android上使用OpenCV進行數字識別](http://stackoverflow.com/questions/10107258/digit-recogntion-using-opencv-on-android) – karlphillip 2012-04-23 17:50:27