Hello,everyone:
I have fine tuned a new lstm model named engtuned.traineddata. I have test it in the command line,it is okay.
In the command line:
PS D:\git_workspace\TableOcrRecognition\Tesserac-OCR-Train> tesseract D:\git_workspace\TableOcrRecognition\TableDetect\TableDetect\Data\Tmp\2.png stdout -l engtuned --psm 7 --oem 3
Warning: Invalid resolution 0 dpi. Using 70 instead.
Q345L90X8
The result is good,but when I used it in C++ code,it can not recognize the characters correctly.Here is my C++ code.
tesseract::TessBaseAPI *tessApi = new tesseract::TessBaseAPI();
// --psm 7 --oem 3
if (tessApi->Init("../../tessdata", "engtuned", tesseract::OcrEngineMode::OEM_DEFAULT)) {
std::cout << "OCRTesseract: Could not initialize tesseract." << std::endl;
return EINITTESS;
}
// setup
tessApi->SetPageSegMode(tesseract::PageSegMode::PSM_SINGLE_LINE);
tessApi->SetVariable("save_best_choices", "T");
...
tessApi->SetImage(binImg.data, binImg.cols, binImg.rows, binImg.step[1], binImg.step[0]);
tessApi->Recognize(0);
string result = std::unique_ptr<char[]>(tessApi->GetUTF8Text()).get();
cout << result < <endl;
I do not know where is wrong,can you help? thanks a lot.