简体   繁体   English

如何在Android中使用OpenCV + Tesseract进行准确的文本识别?

[英]How to use OpenCV+Tesseract for accurate Text recognition in Android?

I am trying to use OpenCV (Android) for processing image taken using camera and then pass it to Tesseract for text (digits) recognition but am not getting good results till the images are very (almost no noise) fine. 我正在尝试使用OpenCV(Android)来处理使用相机拍摄的图像,然后将其传递给Tesseract进行文本(数字)识别,但是直到图像非常(几乎没有噪音)才能获得良好的效果。 Currently I am performing below processing on taken images as: 1. Applying Gaussian blur. 目前我正在对拍摄的图像进行以下处理:1。应用高斯模糊。 2. Adaptive threshold: to binarize the image. 2.自适应阈值:对图像进行二值化。 3. Inverting colours to make background black. 3.反转颜色使背景变黑。 Then passing the processed image to Tesseract. 然后将处理后的图像传递给Tesseract。

But I am not getting good results. 但我没有取得好成绩。

Please suggest what steps/measures I may take further to process image before passing to Tesseract or at stage while processing at Tesseract. 请建议我在进入Tesseract之前或在Tesseract处理阶段进一步处理图像时可采取的步骤/措施。

Also, are there any other better libraries in Android for this? 另外,Android中还有其他更好的库吗?

You can isolate/detect characters in images. 您可以隔离/检测图像中的字符。 This can be done with powerful algorithms such as the Stroke Width Transform . 这可以通过强大的算法完成,例如Stroke Width Transform

The following steps worked well with me: 以下步骤适用于我:

  1. Obtain grayscale of image. 获得图像的灰度。
  2. Perform canny edge detection on grayscale image. 在灰度图像上执行精确边缘检测
  3. Apply gaussian blur on grayscale image(store in seperate matrix) 在灰度图像上应用高斯模糊(以单独矩阵存储)
  4. Input matrices from steps 2 & 3 into SWT algorithm 从步骤2和3输入矩阵到SWT算法
  5. Binarize(threshhold) resulting image. 二值化(阈值)结果图像。
  6. Feed image to tesseract. 将图像输入到tesseract。

Please note, for step 4 you will need to build the c++ library in the link and then import into your android project with JNI wrappers. 请注意,对于第4步,您需要在链接中构建c ++库,然后使用JNI包装器导入到您的android项目中。 Also, you will need to do micro tweaking for all steps to get the best results. 此外,您需要对所有步骤进行微调,以获得最佳效果。 But, this should at least get you started. 但是,这至少应该让你开始。

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

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