我在我的项目中使用pytesseract和cv2,并希望从下面的图像中读取文本(在cv2处理之后): apply to be whitelisted to the new Cloud Tasks API 文本似乎清晰可见,pytesseract正确返回行,但缺少“Da-Dumm”和“Ploink”。
# load the image
image = cv2.imread(args["image"])
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
gray = cv2.threshold(gray, 0, 255,
cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
gray = cv2.medianBlur(gray, 1)
# store grayscale image as a temp file to apply OCR
filename = "Screens/{}.png".format(os.getpid())
cv2.imwrite(filename, gray)
# load the image as a PIL/Pillow image, apply OCR, and then delete the temporary file
text = pytesseract.image_to_string(Image.open(filename),lang="deu")