Python-使用Tesseract获取文本的字体大小

时间:2019-07-09 17:44:59

标签: python-3.x tesseract python-tesseract

我在Python中使用pytesseract库从图像中提取文本。如何获得文本的字体大小?我使用了以下代码:

    image = cv2.imread('sample.png')


    # Get verbose data including boxes, confidences, line and page numbers
    iterator = pytesseract.image_to_data(gray)
    rows = iterator.strip().split('\n')
    arr = [row.split() for row in rows]     
    print(iterator)

迭代器输出如下信息:

enter image description here

arr[4][9] refers to the height of the word in pixels but not the font size. If I use this data to render the word in a canvas, the image will look like the image below:

enter image description here

我想要字体大小,而不是单词的高度(以像素为单位)。有可能吗?

0 个答案:

没有答案