Forgot to tell you, the initlization was successful and the image that I have tried to read is attached to this email.
On Wednesday, March 23, 2022 at 4:39:40 PM UTC+2 [email protected] wrote: > I have implemented OCR with Tesseract 4.1 > (tesseract41.lib/tesseract41.dll), used on a Win10, 64 bit. Tesseract > library also compiled on 64 bit, of course. > > I created a VC++ VS2017 test project, with the following code: > > do > { > std::shared_ptr<tesseract::TessBaseAPI> api = > std::make_shared<tesseract::TessBaseAPI>(); > if (! api->Init(CStringA(GetAppPathTemp() + > GetFileFrom(m_sTrainedFile)), "eng")) > { > sRet.Format(_T("Could not initialize tesseract.")); > break; > } > Pix* pix = pixRead(CStringA(sFile)); > if (! pix) > { > sRet.Format(_T("Could not read the file. Please > assure it is an image file.")); > break; > } > else > { > api->SetImage(pix); > api->Clear(); > api->End(); > pixDestroy(&pix); > } > } while (FALSE); > > Nothing fancy, just simple. *And it works fine*, *until I put the > following code*: > > *api->GetUTF8Text(); *right after *api->SetImage(pix);* > > do > { > std::shared_ptr<tesseract::TessBaseAPI> api = > std::make_shared<tesseract::TessBaseAPI>(); > if (! api->Init(CStringA(GetAppPathTemp() + > GetFileFrom(m_sTrainedFile)), "eng")) > { > sRet.Format(_T("Could not initialize tesseract.")); > break; > } > Pix* pix = pixRead(CStringA(sFile)); > if (! pix) > { > sRet.Format(_T("Could not read the file. Please > assure it is an image file.")); > break; > } > else > { > api->SetImage(pix); > *api->GetUTF8Text();* // <----- > error !!! > api->Clear(); > api->End(); > pixDestroy(&pix); > } > } while (FALSE); > > Why ? Look at the error: > > [image: Untitled.png] > > Can you tell me what I did wrong here ? Do you need extra information to > figure out why I got this error ? > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/tesseract-ocr/a68b3596-8362-43ee-9518-16073625099bn%40googlegroups.com.

