0

I am stuck with following error:

--> Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)

In this particular line of code:

--> outText = string(ocr->GetUTF8Text());

Here is the complete code:

// OCR Process Begins
string outText;
string imPath = argv[2];
// Create Tesseract object
tesseract::TessBaseAPI *ocr = new tesseract::TessBaseAPI();
// Initialize tesseract to use English (eng) and the LSTM OCR engine.
ocr->Init(NULL, "eng", tesseract::OEM_LSTM_ONLY);
// Set Page segmentation mode to PSM_AUTO (3)
ocr->SetPageSegMode(tesseract::PSM_AUTO);
// Open input image using OpenCV
Mat im = cv::imread(imPath, IMREAD_COLOR);
// Set image data
ocr->SetImage(im.data, im.cols, im.rows, 3, static_cast<int>(im.step));
// Run Tesseract OCR on image
outText = string(ocr->GetUTF8Text());
// print recognized text
cout << outText << endl; // Destroy used object and release memory ocr->End();
waitKey();
//return 0 instead of return EXIT_SUCCESS
return EXIT_SUCCESS;

This is a list of errors I'm getting.

Error in pixCreateHeader: width must be > 0 Error in pixCreateNoInit: pixd not made Error in pixCreate: pixd not made Error in pixGetData: pix not defined Error in pixGetWpl: pix not defined Error in pixGetDimensions: pix not defined Error in pixGetColormap: pix not defined Error in pixCopy: pixs not defined Error in pixGetDepth: pix not defined Error in pixGetWpl: pix not defined Error in pixGetYRes: pix not defined Error in pixClone: pixs not defined Please call SetImage before attempting recognition. (lldb)

Thanks in advance

anastaciu
  • 23,467
  • 7
  • 28
  • 53
  • Please present a [Minimal, Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) – anastaciu Jan 25 '20 at 14:08
  • Anastaciu thanks for the help! What do you mean? In the description above there is all the code. –  Jan 25 '20 at 14:11
  • So that is your main function. Ok, see if this helps [EXC_BAD_ACCESS(code=1, address=0x0) occurs when passing a std::map as parameter to a virtual function call](https://stackoverflow.com/questions/23088283/exc-bad-accesscode-1-address-0x0-occurs-when-passing-a-stdmap-as-parameter) – anastaciu Jan 25 '20 at 14:14
  • Okay tomorrow in the morning I will give it a try. Thanks for the help! –  Jan 25 '20 at 20:48

0 Answers0