#!/usr/bin/env python
# -*- coding:utf-8 -*-
# 需要安装的库
# pip install paddlepaddle -i https://mirrors.aliyun.com/pypi/simple/
# pip install paddleocr -i https://mirrors.aliyun.com/pypi/simple/
# pip install cv2 -i https://mirrors.aliyun.com/pypi/simple/
# pip install numpy -i https://mirrors.aliyun.com/pypi/simple/
# pip install Pillow -i https://mirrors.aliyun.com/pypi/simple/
import os
import cv2
import numpy as np
from PIL import Image
from paddleocr import PaddleOCR, draw_ocr
class DeleteImageWatermark:
def __init__(self):
pass
def distinguish_string(self, img_path, lang='ch'):
"""
得到文字识别结果列表
img_path: 图片路径
lang: 默认为识别中文
return: 返回所有被识别到的文字文本框坐标、文字内容和置信度
如:[
[[[1415.0, 977.0], [1482.0, 977.0], [1482.0, 1001.0], [1415.0, 1001.0]], ('小红书', 0.868567168712616)],
[[[1441.0, 1001.0], [1493.0, 1001.0], [1493.0, 1024.0], [1441.0, 1024.0]], ('小红书', 0.9620211124420166)]
]
"""
orc = PaddleOCR(use_angle_cls=True, lang=lang)
result = orc.ocr(img_path, cls=True)
return result
def save_dis
python批量去除图片文字水印
最新推荐文章于 2025-02-11 17:21:49 发布