我尝试使用Tesseract从该图像中提取文本。
我尝试的代码:
img = Image.open('downloadedpng.jpeg').convert('L')
ret,img = cv2.threshold(np.array(img), 125, 255, cv2.THRESH_BINARY)
img = Image.fromarray(img.astype(np.uint8))
print(pytesseract.image_to_string(img))
我得到的输出:
re vie
我用下面的代码尝试了腐蚀和膨胀:
img_erosion = cv2.erode(img, kernel, iterations=1)
img_dilation = cv2.dilate(img, kernel, iterations=1)
但我有错误。 知道如何正确地将其转换为字符串吗
为了获得最佳效果,您应该传递黑白文本:
相关问题 更多 >
编程相关推荐