回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我想检测图像中每个字符的位置。在</p>
<p>我按照<a href="https://stackoverflow.com/questions/32175014/how-to-get-character-position-in-pytesseract">how to get character position in pytesseract</a>中的建议尝试了pytesseract,但给出了一个错误</p>
<pre><code>import csv
import cv2
from pytesseract import pytesseract as pt
pt.run_tesseract('bw.png', 'output', lang=None, boxes=True, config="hocr")
# To read the coordinates
boxes = []
with open('output.box', 'rb') as f:
reader = csv.reader(f, delimiter = ' ')
for row in reader:
if(len(row)==6):
boxes.<a href="https://www.cnpython.com/list/append" class="inner-link">append</a>(row)
# Draw the bounding box
img = cv2.imread('bw.png')
h, w, _ = img.shape
for b in boxes:
img = cv2.rectangle(img,(int(b[1]),h-int(b[2])),(int(b[3]),h-int(b[4])),(255,0,0),2)
cv2.imshow('output',img)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-38-bad5c94b3e13> in <module>()
3 from pytesseract import pytesseract as pt
4
----> 5 pt.run_tesseract('input/1230.jpg', 'output', lang=None, boxes=True, config="hocr")
6
7 # To read the coordinates
TypeError: run_tesseract() got an unexpected keyword argument 'boxes'
</code></pre>
<p>我知道它是为Python2.7开发的,有人能指导我或者给我一个如何在Python3.x上实现它的方法吗</p>
<p>然后我尝试了tesserocr,它似乎无论如何都无法解析tessdata的路径,我尝试使用tesseracct ocr,尝试手动下载tessdata,但仍然存在相同的错误。在</p>
^{pr2}$