识别图片时,"傈僳"二字无法识别出来,在https://aistudio.baidu.com/community/app/91660/webUI 也无法识别出 #14617
Unanswered
PikachuGits
asked this question in
Q&A
Replies: 2 comments 2 replies
-
估计得微调一下识别模型 |
Beta Was this translation helpful? Give feedback.
0 replies
-
也可以试试高精度模型 |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
识别图片时,"傈僳"二字无法识别出来,在https://aistudio.baidu.com/community/app/91660/webUI 也无法识别出
这是随意截取的含有傈僳的图片
这是识别结果
我也尝试了很多方法,issue中给的解决方案
#14601
并不能解决问题, 我查看了包中的字典文件, 是包含这两个字的, 但是在识别是,确实无法识别到
因为才开始接触PaddleOCR , 不清楚应该怎么处理这类的问题, 希望能提供一下解决方案
🏃♂️ Environment (运行环境)
mac i7环境, python 3.9
🌰 Minimal Reproducible Example (最小可复现问题的Demo)
from PIL import Image, ImageEnhance, ImageFilter
from paddleocr import PaddleOCR
import cv2
import numpy as np
import json
import os
初始化 OCR 引擎
ocr = PaddleOCR(use_angle_cls=True)
img_path = "Snipaste_2025-01-27_16-12-27.png"
try:
打开图像
image = Image.open(img_path).convert("RGB")
增强对比度
enhancer = ImageEnhance.Contrast(image)
image = enhancer.enhance(1.5) # 可以根据实际情况调整增强系数
锐化图像
image = image.filter(ImageFilter.SHARPEN)
将 PIL 图像转换为 OpenCV 格式
image_cv = np.array(image)
转换为灰度图
gray_image = cv2.cvtColor(image_cv, cv2.COLOR_BGR2GRAY)
降噪处理,使用中值滤波
denoised_image = cv2.medianBlur(gray_image, 3)
高斯模糊处理
blurred_image = cv2.GaussianBlur(denoised_image, (5, 5), 0)
二值化处理
_, binary_image = cv2.threshold(gray_image, 150, 255, cv2.THRESH_BINARY)
进行 OCR 识别
results = ocr.ocr(binary_image, cls=True)
提取文本行
text_lines = [line[1][0] for line in results[0] if line[1][0].strip()]
print(json.dumps(text_lines, ensure_ascii=False))
if results:
for line in results[0]:
text = line[1][0]
confidence = line[1][1]
print(f"识别文本: {text}, 置信度: {confidence:.2f}")
else:
print("未识别到任何文本信息。")
except FileNotFoundError:
print(f"未找到图像文件: {img_path}")
except Exception as e:
print(f"发生错误: {e}")
Beta Was this translation helpful? Give feedback.
All reactions