command line and code get different result

54 views
Skip to first unread message

易鑫

unread,
Jun 19, 2020, 5:27:55 AM6/19/20
to tesseract-ocr
Hello,every one:

    I use the command line and C++ code to recognize the image text ,but get different result.The image file and traineddata file are in the attachments.
I used this command:

      tesseract test_20200617_1_1854.png stdout -l regular_rgb_layer
The result is -6X201,it is correct.

I also used this C++ code:

    tesseract::TessBaseAPI *tess_rgb_regular = new tesseract::TessBaseAPI();
    //  --oem 3   
    if (tess_rgb_regular->Init("./tessdata", "regular_rgb_layer", tesseract::OcrEngineMode::OEM_DEFAULT)) {
        std::cout << "OCRTesseract: Could not initialize tesseract." << std::endl;
        return EINITTESS;
    }
    tess_rgb_regular->SetVariable("save_best_choices", "T");
    image = cv::imread("test_20200617_1_1854.png");
    tess_rgb_regular->SetImage(image.data, image.cols, image.rows, image.step[1], image.step[0]);    
    tess_rgb_regular->SetSourceResolution(300);
    tess_rgb_regular->Recognize(0);
    string result = std::unique_ptr<char[]>(tessApi->GetUTF8Text()).get();
But the result is -6X20.

Does anyone know the reason,thanks in advabce.


test_20200617_1_1854.png

易鑫

unread,
Jun 22, 2020, 11:18:43 PM6/22/20
to tesseract-ocr
Does anyone knows,thanks.

在 2020年6月19日星期五 UTC+8下午5:27:55,易鑫写道:
Reply all
Reply to author
Forward
0 new messages