将此车牌图像翻译成文本

时间:2019-04-23 14:29:11

标签: python opencv image-processing tesseract python-tesseract

我有一张照片: pic to be cropped

我想把车牌变成文字。

python-opencv裁剪板后:
cropped

pytesseract.image_to_string(bbox, lang='eng', config='--psm 6')返回我:"TH

我的裁剪代码:

coordinates = [[0.6703869047619048, 0.39855072463768115],
               [0.7672123015873016, 0.39855072463768115],
               [0.7672123015873016, 0.47681159420289854],
               [0.6703869047619048, 0.47681159420289854],
               [0.6703869047619048, 0.39855072463768115]]
img = cv.imread(pic)
height, width, channels = img.shape
bbox_coordinates = [[int(coordinate[0] * width), int(coordinate[1] * height)] for coordinate in coordinates]

然后我将其转换为更好的质量,变成灰度:
bbox = cv.cvtColor(bbox, cv.COLOR_BGR2GRAY)

cropped greyscale

pytesseract.image_to_string(bbox, lang='eng', config='--psm 6')返回:To

有没有办法获得WA 6728 M? (无论是否使用pytesseract 4

1 个答案:

答案 0 :(得分:1)

我尝试这张照片:  https://i.stack.imgur.com/HLgiF.jpg

def process_image(image):
    pytesseract.pytesseract.tesseract_cmd = 'C:\\Users\\abenhari\\AppData\\Local\\Tesseract-OCR\\tesseract.exe'
    img = Image.open(image)
    img = img.convert('L')
    pix = img.load()
    plt.imshow(img)
    plt.show()
    return pytesseract.image_to_string(img)

print(process_image("plat1.jpg"))