Trés DuBiel
Trés DuBiel

Reputation: 560

Tesseract failing on openCV Mat (installation issue?)

I thought about putting this on superuser or something, but since my problem has to do with what is happening after compilation, I think here is best.

My system: ubuntu 14.04 g++ 4.9

I am attempting to use tesseract in my C++ program.

So, after quite the struggle, I got tesseract to install with no errors during installation. My problem is that, after compiling and running my program, I get the seemingly rare error of:

index >= 0 && index < size_used_:Error:Assert failed:in file ../ccutil/genericvector.h, line 512
Segmentation fault (core dumped)

What little I could find out about this error is that it can sometimes be caused by missing language data, but I see all of the proper files in the proper folders, according to this.

Software versions: tesseract 3.02.02, leptonica-1.71, libjpeg 8d : libpng 1.2.50 : libtiff 4.0.3 : zlib 1.2.8

My source for the tesseract installation: here. I started by trying tesseract 3.03 but it would fail during make.

I compiled using these flags with no warnings:

g++ -Wall -std=c++11 alt_2.cpp -ggdb `pkg-config --cflags opencv` `pkg-config --cflags tesseract` -o alt_2 `pkg-config --libs opencv` `pkg-config --libs tesseract`

And here is my code that uses tesseract:

#include "tesseract/baseapi.h"
...
tesseract::TessBaseAPI tess;
tess.Init(NULL, lang, tesseract::OEM_DEFAULT);
tess.SetPageSegMode(tesseract::PSM_SINGLE_BLOCK);
tess.SetImage((uchar*)col0.data, col0.cols, col0.rows, 1, col0.cols);

tess.GetUTF8Text();

tess.GetUTF8Text(); is what causes the error. if it is commented out, the error doesn't occur. col0 is my Mat image.

I am all out of ideas and patience with this for the moment. So if any kind soul has experience with this, please help.

Thanks for reading!

Upvotes: 2

Views: 341

Answers (1)

Tr&#233;s DuBiel
Tr&#233;s DuBiel

Reputation: 560

I hate to answer my own questions, but I got it working.

So, I deleted everything and did a fresh install of tesseract 3.0.3. While making the file I still got the error

libtool: link: g++ -std=c++11 -o .libs/tesseract tesseract-
tesseractmain.o  ./.libs/libtesseract.so -lrt -llept -lpthread
./.libs/libtesseract.so: undefined reference to some_leptonic_functions

So what the issue was is that although tesseract -v reported leptonica-1.71, there was also a debian package of it that had been installed by apt-get that was older. So after doing sudo apt-get remove libleptonica-dev the make completed free of errors and I was able to run the code perfectly.

To be clear, this required installing libleptonica and tesseract by source, NOT apt-get.

I hope that this helps someone, because this was a frustrating process.

Upvotes: 5

Related Questions