Openalpr: segmentation fault on openalpr/TesseractOcr

Created on 21 Dec 2018  Â·  11Comments  Â·  Source: openalpr/openalpr

Hello,
I have a problem running openalpr on my web cam (/dev/video1), everytime I turn my camera in front of a license plate the program crash because of a segmentation fault (core dumped)

running openalpr seems to work with sample jpg file but not with my standard webcam over french licence plate

I tried both the python binding and the command line utility, even the docker with docker run --device=/dev/video1 -it --rm -v $(pwd):/data:ro openalpr -c eu /dev/video1 and every time I get the same result (very rare case of success and then crash instantly after the predictions)

I installed OpenAlpr by compiling it (not the dependency): http://doc.openalpr.com/opensource.html#compiling-openalpr and I am running ubuntu 18.04LTS

Standard crash

➜ alpr -c eu /dev/video1 
[1]    25427 segmentation fault (core dumped)  alpr -c eu /dev/video1

valgrind
➜ valgrind alpr -c eu /dev/video1 ==25180== Memcheck, a memory error detector ==25180== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==25180== Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info ==25180== Command: alpr -c eu /dev/video1 ==25180== ==25180== Conditional jump or move depends on uninitialised value(s) ==25180== at 0xD923C36: nextOnPixelInRasterLow (in /usr/lib/x86_64-linux-gnu/liblept.so.5.0.2) ==25180== by 0xD923E7F: nextOnPixelInRaster (in /usr/lib/x86_64-linux-gnu/liblept.so.5.0.2) ==25180== by 0xD925019: pixConnCompBB (in /usr/lib/x86_64-linux-gnu/liblept.so.5.0.2) ==25180== by 0xD8DD91C: ??? (in /usr/lib/x86_64-linux-gnu/liblept.so.5.0.2) ==25180== by 0xD8DDF92: ??? (in /usr/lib/x86_64-linux-gnu/liblept.so.5.0.2) ==25180== by 0xD8DEA42: bmfCreate (in /usr/lib/x86_64-linux-gnu/liblept.so.5.0.2) ==25180== by 0x67EDE0E: tesseract::Tesseract::Tesseract() (in /usr/lib/x86_64-linux-gnu/libtesseract.so.4.0.0) ==25180== by 0x6795F55: tesseract::TessBaseAPI::Init(char const*, int, char const*, tesseract::OcrEngineMode, char**, int, GenericVector<STRING> const*, GenericVector<STRING> const*, bool, bool (*)(STRING const&, GenericVector<char>*)) (in /usr/lib/x86_64-linux-gnu/libtesseract.so.4.0.0) ==25180== by 0x67963A5: tesseract::TessBaseAPI::Init(char const*, char const*, tesseract::OcrEngineMode, char**, int, GenericVector<STRING> const*, GenericVector<STRING> const*, bool) (in /usr/lib/x86_64-linux-gnu/libtesseract.so.4.0.0) ==25180== by 0x4FAA5BE: tesseract::TessBaseAPI::Init(char const*, char const*) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x4FA95A5: alpr::TesseractOcr::TesseractOcr(alpr::Config*) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x4FAB9D2: alpr::createOcr(alpr::Config*) (in /usr/lib/libopenalpr.so.2) ==25180== ==25180== Conditional jump or move depends on uninitialised value(s) ==25180== at 0xD923C6B: nextOnPixelInRasterLow (in /usr/lib/x86_64-linux-gnu/liblept.so.5.0.2) ==25180== by 0xD923E7F: nextOnPixelInRaster (in /usr/lib/x86_64-linux-gnu/liblept.so.5.0.2) ==25180== by 0xD925019: pixConnCompBB (in /usr/lib/x86_64-linux-gnu/liblept.so.5.0.2) ==25180== by 0xD8DD91C: ??? (in /usr/lib/x86_64-linux-gnu/liblept.so.5.0.2) ==25180== by 0xD8DDF92: ??? (in /usr/lib/x86_64-linux-gnu/liblept.so.5.0.2) ==25180== by 0xD8DEA42: bmfCreate (in /usr/lib/x86_64-linux-gnu/liblept.so.5.0.2) ==25180== by 0x67EDE0E: tesseract::Tesseract::Tesseract() (in /usr/lib/x86_64-linux-gnu/libtesseract.so.4.0.0) ==25180== by 0x6795F55: tesseract::TessBaseAPI::Init(char const*, int, char const*, tesseract::OcrEngineMode, char**, int, GenericVector<STRING> const*, GenericVector<STRING> const*, bool, bool (*)(STRING const&, GenericVector<char>*)) (in /usr/lib/x86_64-linux-gnu/libtesseract.so.4.0.0) ==25180== by 0x67963A5: tesseract::TessBaseAPI::Init(char const*, char const*, tesseract::OcrEngineMode, char**, int, GenericVector<STRING> const*, GenericVector<STRING> const*, bool) (in /usr/lib/x86_64-linux-gnu/libtesseract.so.4.0.0) ==25180== by 0x4FAA5BE: tesseract::TessBaseAPI::Init(char const*, char const*) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x4FA95A5: alpr::TesseractOcr::TesseractOcr(alpr::Config*) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x4FAB9D2: alpr::createOcr(alpr::Config*) (in /usr/lib/libopenalpr.so.2) ==25180== ==25180== Invalid read of size 8 ==25180== at 0x67C7568: tesseract::LTRResultIterator::WordFontAttributes(bool*, bool*, bool*, bool*, bool*, bool*, int*, int*) const (in /usr/lib/x86_64-linux-gnu/libtesseract.so.4.0.0) ==25180== by 0x4FA9B7F: alpr::TesseractOcr::recognize_line(int, alpr::PipelineData*) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x4FAB52E: alpr::OCR::performOCR(alpr::PipelineData*) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x4F6DDF9: alpr::AlprImpl::analyzeSingleCountry(cv::Mat, cv::Mat, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x4F6C8BF: alpr::AlprImpl::recognizeFullDetails(cv::Mat, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x4F6F2B6: alpr::AlprImpl::recognize(cv::Mat, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x4F6EF0F: alpr::AlprImpl::recognize(unsigned char*, int, int, int, std::vector<alpr::AlprRegionOfInterest, std::allocator<alpr::AlprRegionOfInterest> >) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x4F670E3: alpr::Alpr::recognize(unsigned char*, int, int, int, std::vector<alpr::AlprRegionOfInterest, std::allocator<alpr::AlprRegionOfInterest> >) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x1414C5: detectandshow(alpr::Alpr*, cv::Mat, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool) (in /usr/bin/alpr) ==25180== by 0x13EF65: main (in /usr/bin/alpr) ==25180== Address 0x8 is not stack'd, malloc'd or (recently) free'd ==25180== ==25180== ==25180== Process terminating with default action of signal 11 (SIGSEGV) ==25180== Access not within mapped region at address 0x8 ==25180== at 0x67C7568: tesseract::LTRResultIterator::WordFontAttributes(bool*, bool*, bool*, bool*, bool*, bool*, int*, int*) const (in /usr/lib/x86_64-linux-gnu/libtesseract.so.4.0.0) ==25180== by 0x4FA9B7F: alpr::TesseractOcr::recognize_line(int, alpr::PipelineData*) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x4FAB52E: alpr::OCR::performOCR(alpr::PipelineData*) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x4F6DDF9: alpr::AlprImpl::analyzeSingleCountry(cv::Mat, cv::Mat, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x4F6C8BF: alpr::AlprImpl::recognizeFullDetails(cv::Mat, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x4F6F2B6: alpr::AlprImpl::recognize(cv::Mat, std::vector<cv::Rect_<int>, std::allocator<cv::Rect_<int> > >) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x4F6EF0F: alpr::AlprImpl::recognize(unsigned char*, int, int, int, std::vector<alpr::AlprRegionOfInterest, std::allocator<alpr::AlprRegionOfInterest> >) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x4F670E3: alpr::Alpr::recognize(unsigned char*, int, int, int, std::vector<alpr::AlprRegionOfInterest, std::allocator<alpr::AlprRegionOfInterest> >) (in /usr/lib/libopenalpr.so.2) ==25180== by 0x1414C5: detectandshow(alpr::Alpr*, cv::Mat, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool) (in /usr/bin/alpr) ==25180== by 0x13EF65: main (in /usr/bin/alpr) ==25180== If you believe this happened as a result of a stack ==25180== overflow in your program's main thread (unlikely but ==25180== possible), you can try to increase the size of the ==25180== main thread stack using the --main-stacksize= flag. ==25180== The main thread stack size used in this run was 8388608. ==25180== ==25180== HEAP SUMMARY: ==25180== in use at exit: 46,850,402 bytes in 127,073 blocks ==25180== total heap usage: 463,968 allocs, 336,895 frees, 262,349,856 bytes allocated ==25180== ==25180== LEAK SUMMARY: ==25180== definitely lost: 0 bytes in 0 blocks ==25180== indirectly lost: 0 bytes in 0 blocks ==25180== possibly lost: 38,457,401 bytes in 165 blocks ==25180== still reachable: 8,393,001 bytes in 126,908 blocks ==25180== of which reachable via heuristic: ==25180== newarray : 125,264 bytes in 176 blocks ==25180== suppressed: 0 bytes in 0 blocks ==25180== Rerun with --leak-check=full to see details of leaked memory ==25180== ==25180== For counts of detected and suppressed errors, rerun with: -v ==25180== Use --track-origins=yes to see where uninitialised values come from ==25180== ERROR SUMMARY: 170 errors from 3 contexts (suppressed: 0 from 0) [1] 25180 segmentation fault (core dumped) valgrind alpr -c eu /dev/video1

Most helpful comment

I had this issue too. What I found is that there was a bug in the tesseract-ocr program. It has been fixed and patched but the fix has not made its way downstream into Ubuntu's repos yet.

Hard: clone, compile and install tesseract from GitHub.
Easy: Visit this PPA. Add to your repos, update tesseract-ocr. Should work then.

All 11 comments

I had this issue too. What I found is that there was a bug in the tesseract-ocr program. It has been fixed and patched but the fix has not made its way downstream into Ubuntu's repos yet.

Hard: clone, compile and install tesseract from GitHub.
Easy: Visit this PPA. Add to your repos, update tesseract-ocr. Should work then.

This is working great !
Thanks !

@calfax I have encountering this problem too, in running the openalpr with Ip stream/realtime. I installed the easy-way. What do you think will fix this issue? Please help me. It will run for a moment, then I will automatically close displaying the segmetantion fault core dumped

@alucard079 fix is to run

sudo add-apt-repository ppa:alex-p/tesseract-ocr -y
sudo apt-get update -y

then reinstall tesseract via apt (if you are ubuntu)

I had this issue too. What I found is that there was a bug in the tesseract-ocr program. It has been fixed and patched but the fix has not made its way downstream into Ubuntu's repos yet.

Hard: clone, compile and install tesseract from GitHub.
Easy: Visit this PPA. Add to your repos, update tesseract-ocr. Should work then.

Didn't really help. That lp.jpg file one downloads by following the Compiling Instructions still leads to "Segmentation Fault (core dumped)" error message.

man page says:

License plate recognition software can never achieve 100% accuracy.  In cases where the 
plate is not recognized correctly, there is diagnostic information available.  You 
can modify the openalpr.conf file to turn "debug" information on.

In the [debug] section toggle the various debug options to enabled by changing the '0' 
value to a '1'.  Some of these options will output text to the CLI and others may output 
images to the GUI.

Try to turn on the debug options and see if that gives you more information.

I can confirm: building Tesseract Release 4.0.0 from source and installing solved the problem.

Source: https://github.com/tesseract-ocr/tesseract/archive/4.0.0.tar.gz
Compile:

    cd tesseract-4.0.0
    ./autogen.sh
    ./configure
    make -j4
    sudo make install
    sudo ldconfig

Combining all comments here, the steps are -

Add the tesseract PPA to your repo list
sudo add-apt-repository ppa:alex-p/tesseract-ocr -y
sudo apt-get update -y

Reinstall tesseract
sudo apt-get purge libtesseract-dev
sudo apt-get install libtesseract-dev

same issue, @TdevSoft fix with the PPA repos fixed it for me. "Ubuntu 18.04.4 LTS" running under Win10 linux subsystem

Hello everyone,

Same issue here.

I just downloaded the last version of tesseract, build and re-build openalpr. And it works!!! Thanks to @DmitriiCM

wget https://github.com/tesseract-ocr/tesseract/archive/4.0.0.tar.gz
gunzip 4.0.0.tar.gz
tar -xvf 4.0.0.tar
cd tesseract-4.0.0/
./autogen.sh
./configure
make -j4
sudo make install
sudo ldconfig

And then:

cd openalpr/src
cmake ./
make
sudo make install
sudo ldconfig

Hope this help you.
Saludos desde Argentina (this explain my english...sorry)

I can confirm: building Tesseract Release 4.0.0 from source and installing solved the problem.

Source: https://github.com/tesseract-ocr/tesseract/archive/4.0.0.tar.gz
Compile:

    cd tesseract-4.0.0
    ./autogen.sh
    ./configure
    make -j4
    sudo make install
    sudo ldconfig

Worked for me. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

moeiscool picture moeiscool  Â·  11Comments

laplasz picture laplasz  Â·  4Comments

guyingqiong picture guyingqiong  Â·  10Comments

Lepiloff picture Lepiloff  Â·  6Comments

tmscer picture tmscer  Â·  8Comments