how to get character position in pytesseract

前端 未结 3 1325
遥遥无期
遥遥无期 2020-12-20 17:26

I am trying to get character position of image files using pytesseract library .

import pytesseract
from PIL import Image
print pytesseract.image_to_string(I         


        
3条回答
  •  星月不相逢
    2020-12-20 18:07

    Did you try use pytesseract.image_to_data()?

    data = pytesseract.image_to_data(img, output_type=Output.DICT)
    boxes = len(data['level'])
    for i in range(boxes ):
        (x, y, w, h) = (data['left'][i], data['top'][i], data['width'][i], data['height'][i])
        #Draw box        
        cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
    

提交回复
热议问题