简体   繁体   English

使用 Tesseract python 进行数字识别

[英]Digit Recognition with Tesseract python

For one of the projects I am working on, I am trying to detect digits on a food tray image using OCR.对于我正在进行的一个项目,我正在尝试使用 OCR 检测食物托盘图像上的数字。 I used Tesseract 4 in python for this purpose.为此,我在 python 中使用了 Tesseract 4。 But it fails to correctly detect the numbers for most of the images I have.但它无法正确检测我拥有的大多数图像的数字。 I tried various image preprocessing such as blurring, threshold, sharpening, erosion and dilation using OpenCV to improve the accuracy.我尝试使用 OpenCV 进行各种图像预处理,例如模糊、阈值、锐化、腐蚀和膨胀,以提高精度。 But nothing seems to work.但似乎没有任何效果。 I am newbie to computer vision, so any suggestions or alternate solutions for this would be of great help.我是计算机视觉的新手,因此对此的任何建议或替代解决方案都会有很大帮助。 I have attached the images in the link below.我在下面的链接中附上了图片。 thanks in advance.提前致谢。

Link to Images 链接到图片

You need a stronger text detection which will crop the text-candidate region for you.您需要更强大的文本检测功能,它会为您裁剪文本候选区域。

The processing will be a little more complicated as follow:处理会稍微复杂一些,如下所示:

  1. Run text detection, get the text-candidated region运行文本检测,获取文本候选区域
  2. Extract that region提取该区域
  3. Use tesseract to read the text使用 tesseract 读取文本

Inside OpenCV's DNN modules have the great text detection script called: text_detection.py which is used EAST text detection.在 OpenCV 的 DNN 模块内部有一个很棒的文本检测脚本,称为: text_detection.py ,它用于 EAST 文本检测。 Using your sample images, i can extract the following text-candidate region in green rectangle.使用您的示例图像,我可以在绿色矩形中提取以下文本候选区域。 So the next steps is the above step 2 and 3.所以接下来的步骤就是上面的第2步和第3步。

在此处输入图像描述

在此处输入图像描述

For sure, EAST is not trained for your scenario so 100% accuracy is impossible.当然,EAST 没有针对您的场景进行训练,因此不可能达到 100% 的准确性。 You could try to gather data and train EAST for your scenario.您可以尝试为您的场景收集数据并训练 EAST。 But i think, the default one will give you more than 90% in accuracy.但我认为,默认值会给你 90% 以上的准确率。

Hope this help.希望这有帮助。

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

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