Ask Your Question

Opencv tesseract run() function run into segmentation fault

asked 2017-01-04 12:00:30 -0500

Anonymous9951 gravatar image

updated 2017-01-04 13:48:45 -0500

Here is my code, I'm not sure why I only run into segmentation fault when perform


void Char_Reg( Mat& img, vector<string>& txt, vector<Rect>& loc)
Ptr<text::OCRTesseract> reg;
vector<Rect> a ;
vector<string> b ;
vector<float> c ;
string num;

for(int i=0; i<loc.size(); i++)
Mat plt=img(loc[i]);
adaptiveThreshold(plt,plt, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 15, 5.5);
reg->run(plt, num,&a, &b, &c,5);
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-01-04 15:33:03 -0500

berak gravatar image

updated 2017-01-04 15:40:23 -0500

your reg object was never initialized. you're lacking code like:

Ptr<text::OCRTesseract> reg = text::OCRTesseract::create();

please see docs

(then, you probably should not allocate such an object per detection, but only once per runtime)

edit flag offensive delete link more


But by right it should use the default value if I not initialize it, doesn't it?

Anonymous9951 gravatar imageAnonymous9951 ( 2017-01-04 22:28:49 -0500 )edit

@berak thank you, I found my problem, yes you are right, I have to initialize it before i can use it, before that I'm using wrong syntax that's why I run into segmentation fault.

Anonymous9951 gravatar imageAnonymous9951 ( 2017-01-04 22:41:45 -0500 )edit

Question Tools

1 follower


Asked: 2017-01-04 11:55:21 -0500

Seen: 186 times

Last updated: Jan 04 '17