从图像中提取文本

Yas*_*ora 4 python ocr tesseract image-processing python-tesseract

我正致力于从图像中提取文本.

最初图像用白色文本着色,在进一步处理图像时,文本显示为黑色,其他像素为白色(带有一些噪声),这里是一个示例:

现在,当我尝试使用pytesseract(tesseract)进行OCR时,我仍然没有得到任何文本.

是否有可能从彩色图像中提取文本?

Dee*_*Raj 6

from PIL import Image
import pytesseract
import argparse
import cv2

# construct the argument parser and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", required=True, help="Path to the image")
args = vars(ap.parse_args())

# load the image and convert it to grayscale
image = cv2.imread(args["image"])
cv2.imshow("Original", image)

# Apply an "average" blur to the image

blurred = cv2.blur(image, (3,3))
cv2.imshow("Blurred_image", blurred)
img = Image.fromarray(blurred)
text = pytesseract.image_to_string(img, lang='eng')
print (text)
cv2.waitKey(0)
Run Code Online (Sandbox Code Playgroud)

结果我得到="住在:Overwoter Bungalow $ 3»"

那么使用Contour并从中获取不必要的斑点呢?可能有用