我试图在Python上使用PyteSeract从图像中提取文本.这是我想要提取文本的图像:
这是应用阈值后的图像:
控制台输出:
20 hours
20 hours
Bhours
这是我正在使用的代码:
from pytesseract import *
import cv2
path = r"path where image is located" #path of image
folderPath = r"path for saving output image"
grey_image = cv2.imread(path,0) #import image
_,bt = cv2.threshold(grey_image, 150 ,255,cv2.THRESH_BINARY) #variable means binary threshold
cv2.imwrite(folderPath + "\\" + "test.png", bt) #Saving result
imageout = pytesseract.image_to_string(bt) #Convert image to text
print(imageout) #Print text in console
我一直在try 不同的阈值范围,但仍然无法获得精确的输出.
为了得到准确的结果,你有什么建议?