【发布时间】:2020-03-15 07:36:37
【问题描述】:
我正在尝试 OCR 标准表格(正面和背面都被扫描)
我只想对扫描中的第二张图像(带有文本信息的图像)进行 OCR - 有没有办法检测和分割它们,并且只处理正确的图像?对不起,如果我错过了一些重要的东西,刚刚开始。
import pytesseract as tess
import os
from PIL import Image
import pandas as pd
import tesserocr
path = "/Users/oliviervandhuynslager/PycharmProjects/OCR/DC_SCANS_TEST" ##path to directory (folder) where the images are located
count = 0
fileName = [] #create empty list that will contain the original filenames
fullText = [] #create empty list to store the OCR results per file
for imageName in os.listdir("/Users/oliviervandhuynslager/PycharmProjects/OCR/DC_SCANS_TEST"):
count = count + 1
fileName.append(imageName)
fileName.sort()#generate list from texts.
#%%
# APPEND (OCR) text from images TO LIST fullText
for imageName in os.listdir("/Users/oliviervandhuynslager/PycharmProjects/OCR/DC_SCANS_TEST"):
inputPath = os.path.join(path, imageName)
img = Image.open(inputPath)
text = tess.image_to_string(img, lang="eng")
fullText.append(text)
【问题讨论】:
-
背景颜色会一直是白色吗?图像的颜色也会相同吗?图像的位置会大致相同吗?
-
是的,以上所有!它们是非常标准化的形式。