Ask Your Question
0

Opencv tesseract run() function run into segmentation fault

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

Anonymous9951 gravatar image

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

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

reg->run()

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]);
cvtColor(plt,plt,CV_GRAYSCALE);
adaptiveThreshold(plt,plt, 255, CV_ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 15, 5.5);
imshow("plt",plt);
reg->run(plt, num,&a, &b, &c,5);
cout<<num<<endl;
}
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

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

berak gravatar image

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

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

Comments

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 -0600 )edit
1

@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 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 242 times

Last updated: Jan 04 '17