深度学习系列59:文字识别

1. 简单文本:

使用google加的tesseract,效果不错。
首先安装tesseract,在mac直接brew install即可。
python调用代码:

import pytesseract
from PIL import Image
img = Image.open('1.png')
pytesseract.image_to_string(img, lang='chi_sim+eng')

2. 结构化文本

使用百度家的paddleocr可以达成如下效果:
在这里插入图片描述

安装方法:pip install “paddleocr>=2.2”,调用代码。
其中画图的部分如果要用的话,需要下载字体库:!git clone https://gh.api.99988866.xyz/https://github.com/PaddlePaddle/PaddleOCR;不需要画图的话,注释掉即可。

import os
import cv2
from paddleocr import PPStructure, draw_structure_result, save_structure_res
from PIL import Image


def Structure_analysis(img_path):
    table_engine = PPStructure(show_log=True)
    save_folder = './output/table'
    img = cv2.imread(img_path)
    result = table_engine(img)1
    save_structure_res(result, save_folder,os.path.basename(img_path).split('.')[0])

    for line in result:
        line.pop('img')
        print(line)

    font_path = '../PaddleOCR/doc/fonts/simfang.ttf' # PaddleOCR下提供字体包
    image = Image.open(img_path).convert('RGB')
    im_show = draw_structure_result(image, result, font_path=font_path)
    im_show = Image.fromarray(im_show)
    im_show.save('result.jpg')
    pass

Structure_analysis('1.png')

相关推荐

  1. 基于深度学习的水果识别系统

    2024-02-22 05:58:05       21 阅读
  2. Python - 深度学习系列36 重塑实体识别3

    2024-02-22 05:58:05       21 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-02-22 05:58:05       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-02-22 05:58:05       100 阅读
  3. 在Django里面运行非项目文件

    2024-02-22 05:58:05       82 阅读
  4. Python语言-面向对象

    2024-02-22 05:58:05       91 阅读

热门阅读

  1. 单例模式的介绍

    2024-02-22 05:58:05       54 阅读
  2. 利用电商数据API接口上货、铺货

    2024-02-22 05:58:05       57 阅读
  3. 设计模式浅析(五) ·单例模式

    2024-02-22 05:58:05       52 阅读
  4. Python编程语言学习

    2024-02-22 05:58:05       40 阅读
  5. C++基本格式

    2024-02-22 05:58:05       46 阅读
  6. 网安初探-春秋云镜

    2024-02-22 05:58:05       48 阅读
  7. Vue常用指令+用法举例 详解

    2024-02-22 05:58:05       58 阅读
  8. SEO优化对服务器有影响

    2024-02-22 05:58:05       50 阅读
  9. 时序电路的Verilog设计——基本时序元件

    2024-02-22 05:58:05       42 阅读
  10. 算法刷题day15

    2024-02-22 05:58:05       60 阅读
  11. 【C++】每周一题——1024.2.21

    2024-02-22 05:58:05       51 阅读
  12. 个人搭建部署gpt站点

    2024-02-22 05:58:05       47 阅读
  13. 大白话解析LevelDB: Block Iterator

    2024-02-22 05:58:05       44 阅读