python PaddleOCR库的介绍
小妮浅浅
2021-07-17 14:38:136153浏览 · 0收藏 · 0评论

说明
1、PaddleOCR是基于深度学习的ocr识别库,中文识别精度相当还不错,能够应对大多数文字提取需求。
2、需要依次安装三个依赖库,shapely库可能会受到系统的影响,出现安装错误。
安装命令
pip install paddlepaddle pip install shapely pip install paddleocr
代码实现
    ocr = PaddleOCR(use_angle_cls=True,)
    # 输入待识别图片路径
    img_path = r"d:\Desktop\4A34A16F-6B12-4ffc-88C6-FC86E4DF6912.png"
    # 输出结果保存路径
    result = ocr.ocr(img_path, cls=True)
    for line in result:
        print(line)
 
    from PIL import Image
    image = Image.open(img_path).convert('RGB')
    boxes = [line[0] for line in result]
    txts = [line[1][0] for line in result]
    scores = [line[1][1] for line in result]
    im_show = draw_ocr(image, boxes, txts, scores)
    im_show = Image.fromarray(im_show)
    im_show.show()以上就是python PaddleOCR库的介绍,希望对大家有所帮助。更多Python学习指路:python基础教程
                    关注公众号,随时随地在线学习
相关文章