【问题标题】:Finding table regions with pytesseract使用 pytesseract 查找表区域
【发布时间】:2018-12-15 05:10:02
【问题描述】:

我目前正在使用 Windows 7、Python 3.6 和 pytesseract 处理扫描图像。图像包含文本和表格区域 - 它看起来有点像这样:https://tex.stackexchange.com/questions/49300/wrap-text-around-a-tabular

我想获取表格区域的坐标,以便将图像裁剪到该部分。显然,tesseract 定义了具有不同属性的区域(PolyBlockTypes 参见https://tesseract.patagames.com/help/html/T_Patagames_Ocr_Enums_PolyBlockType.htm) - 但我不知道如何使用 pytesseract 获取该信息。

谁能帮帮我?我想通过使用 pytesseract 或其他 python 函数来解决这个问题。

编辑:我目前的做法是

pytesseract.image_to_data(image='< ... >', config='-c gapmap_debug=1')

虽然配置 gapmap_debug=1 似乎没有任何效果......至少我没有得到输出。我错过了什么吗?更多配置选项请见http://www.sk-spell.sk.cx/tesseract-ocr-parameters-in-302-version

【问题讨论】:

标签: python image-processing python-tesseract


【解决方案1】:

尝试下面的代码,识别电话号码(置信度>70),例如phone number img 来自img数据并保存到一个特殊文件夹

data = pytesseract.image_to_data(image, lang='eng', config='outputbase digits', output_type = pytesseract.Output.DICT)
    text = data['text']
    confidence = data['conf'][len(text)-1]
    phone_number = data['text'][len(text)-1]
    print(image.filename, "  confidence" , confidence , "  phone_number" , phone_number)
    if confidence>=70 and len(phone_number.strip())> 10:
        changeFileName = image.filename
        newName = image.filename[0:len(image.filename)-5] + phone_number +".jpg";
        newFileName = os.path.basename(newName) 
        image.save('./recognize/'+newFileName, 'JPEG')
        os.remove(image.filename) 
        print( "old" + changeFileName +"\nnew"+ newName)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-10-22
    • 1970-01-01
    • 1970-01-01
    • 2019-01-08
    • 1970-01-01
    • 2012-06-18
    • 2011-03-09
    • 1970-01-01
    相关资源
    最近更新 更多