zdenop / qt-box-editor

QT4 editor of tesseract-ocr box files
https://zdenop.github.io/qt-box-editor/
Apache License 2.0
170 stars 66 forks source link

crashes when you load image. #76

Closed simonmeaden closed 5 years ago

simonmeaden commented 5 years ago

the app crashes with a segmentation fault when I try to load the image. It pops up a message informing me that I need to set up Tesseract (done). The error message is:

!strcmp(locale, "C"):Error:Assert failed:in file baseapi.cpp, line 209 Segmentation fault (core dumped)

which seems to be the command

ASSERT_HOST(!strcmp(locale, "C"));

The locale is not "C" so this should pass.

Running on : Fedora Linux 30, but also happened on 29 QT 5.12.1 g++ (GCC) 9.0.1 20190312 (Red Hat 9.0.1-0.10)

simonmeaden commented 5 years ago

Just a further note I am using the latest tesseract version 5.0.0-alpha according to the VERSION file. the value of locale is "LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=en_GB.UTF-8" and tesseract from the installed build seems to work fine.

simonmeaden commented 5 years ago

OK I've done some investigation and looking at the TessBaseAPI code you get

const char *locale; locale = std::setlocale(LC_ALL, nullptr); ASSERT_HOST(!strcmp(locale, "C")); the value of setlocale with nullptr should return a minimal locale according to the docs but it doesn't seem to return "C" but "LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=en_GB.UTF-8" at least on my linux, strcmp returns a non-zero value which is what I would expect and ASSERT_HOST basically just builds the error message. I am not usually a C user as I use CPP almost exclusively unless working with a C library but to me it looks like the problem may be in the tesseract library which seems to expect "C".

simonmeaden commented 5 years ago

OK i take that back. I just noticed that you set the locale in TessTools line 78 with setlocale(LC_NUMERIC, "C"); if you use LC_ALL instead you do get "C" which the api expects and it works.

zdenop commented 5 years ago

this project was targeting for tesseract 3.05 ad it worked with it. I did not test it for tesseract 4.0 and about, because it use different approach for box file creations...

simonmeaden commented 5 years ago

OK I was writing an app to scan multiple page documents and found your app and wondered if I could use it. I'll go my own way as its well along anyway.

Regards Simon Meaden

⁣Sent from BlueMail ​

On 7 May 2019, 10:27, at 10:27, zdenop notifications@github.com wrote:

this project was targeting for tesseract 3.05 ad it worked with it. I did not test it for tesseract 4.0 and about, because it use different approach for box file creations...

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/zdenop/qt-box-editor/issues/76#issuecomment-490005922

zdenop commented 5 years ago

thanks anyway: I fixed it in 75a68b466868ba41ba2886caa796057403fe1901.