我正在使用JNI开发适用于Android的OCR应用程序,并使用OpenCV和Tesseract在C ++下开发代码。它将用于从应用程序拍摄的照片中读取带有字母数字ID的徽章。
我开发了一个处理图像预处理的代码,以获取如下所示的“可读图像”:
我编写了以下函数,用于使用tesseract“读取”图像:
char* read_text(Mat input_image)
{
tesseract::TessBaseAPI text_recognizer;
text_recognizer.Init("/usr/share/tesseract-ocr/tessdata", "eng", tesseract::OEM_TESSERACT_ONLY);
text_recognizer.SetVariable("tessedit_char_whitelist", "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
text_recognizer.SetImage((uchar*)input_image.data, input_image.cols, input_image.rows, input_image.channels(), input_image.step1());
text_recognizer.Recognize(NULL);
return text_recognizer.GetUTF8Text();
}
预期的结果是“ KQ 978 A3705”,但是我得到的是“ KO 978 H375”。
I did all the recommendations for improving the quality of the image from https://github.com/tesseract-ocr/tesseract/wiki/ImproveQuality. In addition, reading the docs from https://github.com/tesseract-ocr/docs, I tryed using an approximation of the images using polygons in order to get "better" features. The image I used is one like this:
With this image, I get "KO 978 A3705". The result is clearly better than the previous one, but is not fine.
I think that the processed image I pass to tesseract is fine enought to get a good result and I don't get it. I don't know what else to do, so I ask you for ideas in order to solve this problem. I need an exact result and I think I could get it with the processed image I get. Ideas please! =)
我注意到通过一些扩张,ORC结果的改善令人难以置信!对我来说,这就是解决方案
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句