简体   繁体   English

使用 pytesseract 检测孟加拉语数字和字符

[英]Detecting Bangla digit and character using pytesseract

I am trying to detect Bangla characters from images of Bangla number plates using Python, so I decided to use pytesseract .我正在尝试使用 Python 从孟加拉车牌图像中detect Bangla characters ,因此我决定使用pytesseract For this purpose I have used below code:为此,我使用了以下代码:

import pytesseract
from PIL import Image

pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files (x86)/Tesseract-OCR/tesseract'
text = pytesseract.image_to_string(Image.open('input.png'),lang="ben")
print(text)

The problem is when I am printing, it is showing as empty output.问题是当我打印时,它显示为空输出。

在此处输入图片说明

When I tried to freeze it in a text, it is showing like:当我尝试将其冻结在文本中时,它显示如下:

在此处输入图片说明

Example Picture: (Link)示例图片:(链接)

在此处输入图片说明

Expected Output (should be something like):预期输出(应该是这样的):

ঢাকা মেট্রো হ ঢাকামেট্রোহ

৪৫ ২৩০৭ ৪৫২৩০৭

PS: I have downloaded Bengali language data while installing Tesseract-OCR-64 and I am trying to run it in VS Code . PS:我在安装Tesseract-OCR-64时下载了孟加拉语数据,我试图在VS Code运行它。

Can anyone help me to solve this problem or give me an idea of how to solve this problem?谁能帮我解决这个问题或给我一个如何解决这个问题的想法?

The solution to this problem is:这个问题的解决方法是:

You need to segment all the characters (you can take any approach if you want, can be deep learning or image processing ) and feed the PyTesseract only the character.您需要分割所有字符(如果需要,您可以采用任何方法,可以是深度学习或图像处理)并仅将字符输入 PyTesseract。 (only clear photos) (只有清晰的照片)

Reason: It can detect the Bangla language from pictures of clear and considerably acceptable resolution.原因:它可以从清晰且相当可接受的分辨率的图片中检测到孟加拉语。 It might have considerably fewer models trained for this language for pictures of small size.对于小尺寸图片,针对这种语言训练的模型可能要少得多。 (which is quite understandable) (这很好理解)

Code:代码:

### any deep learning approach or any image processing approach here

# load the segmented character

import pytesseract
from PIL import Image

pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files (x86)/Tesseract-OCR/tesseract'
character = pytesseract.image_to_string(Image.open('char.png'),lang="ben")
print(character)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM