Why the SetVariable don't work normally?

344 views
Skip to first unread message

朱裕清

unread,
Jan 26, 2018, 2:35:37 PM1/26/18
to tesseract-ocr
This is my image


And this is my code

#include <tesseract/baseapi.h>
#include <leptonica/allheaders.h>


int main()
{
 tesseract
::TessBaseAPI *api = new tesseract::TessBaseAPI();
 api
->Init(".\\tessdata", "eng");
 
Pix *image = pixRead("image.png");
 api
->SetImage(image);
        api
->SetPageSegMode(tesseract::PSM_SINGLE_CHAR);

 api
->SetSourceResolution(300);
 api
->SetVariable("classify_bln_numeric_mode", "1");
 
//api->SetVariable("tessedit_char_whitelist", "0123456789");
 api
->SetRectangle(61, 4, 38, 22);
 
char *outText = api->GetUTF8Text();
 cout
<< outText << endl;
 api
->End();


 
return 0;
}


I will get a character A. Why my SetVariable("classify_bln_numeric_mode", "1"); don't work normally? And even I use SetVariable("tessedit_char_whitelist", "0123456789");. The result is same still. How to read a digit from a specify rectangle?
Message has been deleted

朱裕清

unread,
Jan 31, 2018, 3:56:39 AM1/31/18
to tesseract-ocr
Hi, I'm glad to receive your response. I have to say this problem stumped me some days.. And I'm in newest tesseract 3.05.01 in here.



在 2018年1月31日星期三 UTC+8下午4:44:12,James Q写道:
If you are using tesseract 4 then whitelists/blacklists do not yet work (at least not in LSTM mode). I also get the impression that the 'Control Parameters' list you obtain by typing 'tesseract --print-parameters'on the command line is not updated to the supported functionality in tesseract 4. My advice would by to test a particular variable on command line tesseract to determine if it is supported before trying to set it via an API.

The whitelists/blacklists are supposed to be supported in Tesseract 4 in Tesseract mode I believe, but I haven't managed to get these working at all.

Please let me know how you get on.
Thanks
James
 

yping 

朱裕清

unread,
Jan 31, 2018, 4:20:15 AM1/31/18
to tesseract-ocr
But if I use the command line method in my windows 10. I can get these result




在 2018年1月31日星期三 UTC+8下午4:44:12,James Q写道:
If you are using tesseract 4 then whitelists/blacklists do not yet work (at least not in LSTM mode). I also get the impression that the 'Control Parameters' list you obtain by typing 'tesseract --print-parameters'on the command line is not updated to the supported functionality in tesseract 4. My advice would by to test a particular variable on command line tesseract to determine if it is supported before trying to set it via an API.

The whitelists/blacklists are supposed to be supported in Tesseract 4 in Tesseract mode I believe, but I haven't managed to get these working at all.

Please let me know how you get on.
Thanks
James
 

yping 

On Friday, January 26, 2018 at 7:35:37 PM UTC, 朱裕清 wrote:
Reply all
Reply to author
Forward
0 new messages