Tesseract ocr failed to recognize number from number plate images

104 views
Skip to first unread message

Sangharsh Kamble

unread,
Oct 22, 2019, 4:00:11 AM10/22/19
to tesseract-ocr

2.jpeg

4.jpeg

ALARM_ANPR_2019_09_26_00_09_48_0878_crop.jpg

ALARM_ANPR_2019_09_26_00_48_02_0976_crop.jpg

import cv2
import numpy as np
from PIL import Image
import pytesseract
from scipy import ndimage
from scipy.ndimage import rotate
#from matplotlib import pyplot as plt

import allow_needed_values as anv

img = cv2.imread('path_to_image/1.jpg')
result = cv2.fastNlMeansDenoisingColored(img,None,10,10,7,21)
cv2.imshow("denoise",result)
gray = cv2.cvtColor(result, cv2.COLOR_RGB2GRAY)
cv2.imshow("gray image",gray)

gray = cv2.threshold(gray, 0, 255,cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
cv2.imshow("threshold image", gray)
#cv2.waitKey(delay = 0)
#gray = cv2.medianBlur(gray, 3)
img = cv2.medianBlur(gray,3)
cv2.imshow("median blur", img)
#rot = rotate(img, -6, reshape=False)
#rotated= ndimage.rotate(img,-2)
#cv2.imshow("rotate image", rot)
#result = cv2.fastNlMeansDenoisingColored(img,None,20,10,7,21)
rot = rotate(img, -5, reshape=False)
cv2.imshow("rotate", rot)
tessdata_dir_config = "/usr/share/tesseract-ocr/4.00/tessdata/"
text=pytesseract.image_to_string(rot,lang='eng',config=tessdata_dir_config)
carReg = anv.catch_rectify_plate_characters(text)
print(carReg)
cv2.waitKey(delay = 0)


Here i write the code for number recognition from number plate images,but the tessaract failed to recognize number. I have day light and night images. in most of the case ocr failed on night images. also i apply various filter filter for images clearing and also rotate the image angle for some degree.

I upload the various sample images where tesseract ocr failed.

 

Zdenko Podobny

unread,
Oct 22, 2019, 8:40:42 AM10/22/19
to tesser...@googlegroups.com
Unless you provide clear images (black letters on white background) (maybe with straight text, but this could be handle by leptonica) you can not expect that tesseract will provide you correct results.


Zdenko


ut 22. 10. 2019 o 10:00 Sangharsh Kamble <sanghars...@gmail.com> napísal(a):
--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-oc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tesseract-ocr/b234e604-c0e7-4893-80b0-989a4ceeee13%40googlegroups.com.

Timothy Snyder

unread,
Oct 22, 2019, 11:57:19 AM10/22/19
to tesser...@googlegroups.com
Yes you're going to have to do a significant amount of image processing to transform those license plates into straight black text on a white background. Have you tried out the OpenALPR project?

--

Sangharsh Kamble

unread,
Oct 23, 2019, 1:52:05 AM10/23/19
to tesser...@googlegroups.com
Yes I apply various image filtering process on image  and also go through the OpenAlpr project site. But I have to create my own alpr project so I need this code.

Reply all
Reply to author
Forward
0 new messages