Tessaract在二进制图像上的结果很差

时间:2016-04-08 23:19:14

标签: c++ opencv ocr tesseract opencv3.0

我正在尝试使用tesseract库检测图片中的字母表,该库作为OpenCv3的额外模块。 经过大量的预处理后,我能够得到一张非常体面的字母表图片。 然而,tesserct库根本无法识别它。 enter image description here

这是我到目前为止所写的内容:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/text/ocr.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <stdlib.h>

using namespace cv;
using namespace std;
using namespace cv::text;


Mat img=imread("result.jpg",0);
if(img.empty()){
    cout<<"Image not loaded!!\n";
    return 1;
}
string output_text;
vector<Rect> detected;
vector<string> list;
vector<float> conf;
Ptr<OCRTesseract> ocr = OCRTesseract::create();
ocr->run(img,output_text,&detected,&list,&conf,0);

for(int i=0; i<detected.size(); i++){
    Scalar color = Scalar(255,255,150);
    rectangle( img, detected[i].tl(), detected[i].br(), color, 2, 8, 0 );
}
//cout<<"x="<<detected[0].x<<" y="<<detected[0].y

cout<<"Text found is:\n"<<output_text<<endl;
imshow("My",img);
waitKey(0);
return 0;

人们说Tesseract是我最好的选择。但是我没有得到任何相同的结果。 以下是opencv3的Tesseract Library Documentation的链接。

http://docs.opencv.org/trunk/d7/ddc/classcv_1_1text_1_1OCRTesseract.html#gsc.tab=0

此外,使用原生Tesseract Lib与OpenCV版本之间有什么区别吗?

0 个答案:

没有答案
相关问题