Hi All,

I used the Tesseract 4.0 to extract text from a bitmap but i get a error 
when i call Recognize method.
=> Error : Assertion failed: index >= 0 && index < size_used_, file 
E:\Libs\Text\tesseract-master\src\ccutil\genericvector.h, line 720

Can you help me?

My Code :
        tesseract::TessBaseAPI tess;
const int init_failed = 
tess.Init("e:\\Libs\\Text\\tesseract-master\\tessdata\\", "eng");

if (init_failed == -1)
{
std::cout << "OCRTesseract: Could not initialize tesseract." << std::endl;
return 1;
}

// setup
tess.SetPageSegMode(tesseract::PageSegMode::PSM_AUTO);
tess.SetVariable("save_best_choices", "T");
tess.SetOutputName("out");

// read image
auto pixs = pixRead("C:\\Users\\NhatKhanh\\Desktop\\IMG_1345.bmp");
if (!pixs)
{
std::cout << "Cannot open input file." << std::endl;
return 1;
}

// recognize
tess.SetImage(pixs);
tess.Recognize(0);

// get result and delete[] returned char* string
std::string szText = std::string(tess.GetUTF8Text());
std::cout << std::unique_ptr<char[]>(tess.GetUTF8Text()).get() << std::endl;

// cleanup
tess.Clear();
pixDestroy(&pixs);

-- 
You received this message because you are subscribed to the Google Groups 
"tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tesseract-ocr.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tesseract-ocr/7784ce44-7dd4-4248-a7d3-179a9447a93d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to