error in ocr for text detection

asked 2015-02-20 03:49:33 -0500

updated 2015-02-20 07:39:09 -0500

thdrksdfthmn gravatar image

hi i write a programe for text detection:

#include  "opencv2/text.hpp"
#include  "opencv2/highgui.hpp"
#include  "opencv2/imgproc.hpp"

#include  <vector>
#include  <iostream>
#include  <iomanip>

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

int main()
{
    Mat src, gray, dst;
    string text;
    src = imread("C:/Users/Ali Tabasi/Desktop/matn.png");

    cvtColor(src, gray, COLOR_RGB2GRAY);
    /*adaptiveThreshold(gray, dst, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 3, 5);
    imshow("bin non filter", dst);*/
    GaussianBlur(src, src, Size(3,3), 0, 0, BORDER_CONSTANT);
    cvtColor(src, gray, COLOR_RGB2GRAY);
    adaptiveThreshold(gray, dst, 255, ADAPTIVE_THRESH_GAUSSIAN_C, THRESH_BINARY, 3, 5);

    Ptr<OCRTesseract> ocr = OCRTesseract::create();
    vector<Rect>   boxes;
    vector<string> words;
    vector<float>  confidences;
    ocr->run(dst, text, &boxes, &words, &confidences, OCR_LEVEL_WORD);
    cout << text;

    imshow("gray", gray);
    imshow("input", src);
    imshow("bin", dst);
    waitKey(0);
}

image description i dont know problem? please help me

edit retag flag offensive close merge delete