Following the instruction for OS X at:
https://github.com/openalpr/openalpr/wiki/Compilation-instructions-(OS-X)
The last step before testing the install asks to copy the runtime_data directory
# copy runtime_data
mkdir /usr/local/share/openalpr
cp -r ../../runtime_data /usr/local/share/openalpr/
Running the install test after that gives the following error
wget http://i.imgur.com/pjukRD0.jpg -O lp.jpg
alpr lp.jpg
Error opening data file /usr/local/share/openalpr/runtime_data/ocr/lus.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.
Failed loading language 'lus'
Tesseract couldn't load any languages!
[1] 44280 segmentation fault alpr lp.jpg
The error comes from the fact that the tesseract files are looked up in /usr/local/share/openalpr/runtime_data/ocr/ instead of /usr/local/share/openalpr/runtime_data/ocr/tessdata.
I tried exporting the TESSDATA_PREFIX as indicated by the error message and the following issue in the tesseract repo
https://github.com/tesseract-ocr/tesseract/issues/221
export TESSDATA_PREFIX=/usr/local/share/openalpr/runtime_data/ocr
Still no luck. I also tried the following variants with the same result
export TESSDATA_PREFIX=/usr/local/share/openalpr/runtime_data/ocr
export TESSDATA_PREFIX=tessdata
Looking at this part of the error
Error opening data file /usr/local/share/openalpr/runtime_data/ocr/lus.traineddata
I tried to move the file to /usr/local/share/openalpr/runtime_data/ocr which makes alpr happy
alpr lp.jpg
plate0: 10 results
- 6RUX251 confidence: 95.1969
- 6RUXZ51 confidence: 87.8443
- 6RUX2S1 confidence: 85.4606
- 6RUX25I confidence: 85.4057
- 6ROX251 confidence: 85.3351
- 6RDX251 confidence: 84.7451
- 6R0X251 confidence: 84.7044
- 6RQX251 confidence: 82.9933
- 6RUXZS1 confidence: 78.1079
- 6RUXZ5I confidence: 78.053
From what I see in the code
//openalpr/config/openalpr.conf.defaults
runtime_dir = ${CMAKE_INSTALL_PREFIX}/share/openalpr/runtime_data
//openalpr/src/openalpr/config.cpp
void Config::loadCommonValues(string configFile)
{
...
runtimeBaseDir = getString(ini,defaultIni, "", "runtime_dir", DEFAULT_RUNTIME_DATA_DIR);
...
}
string Config::getTessdataPrefix()
{
return this->runtimeBaseDir + "/ocr/";
}
//openalpr/src/openalpr/ocr/tesseract_ocr.cpp
// Tesseract requires the prefix directory to be set as an env variable
tesseract.Init(config->getTessdataPrefix().c_str(), config->ocrLanguage.c_str() );
Although the comment above tesseract.Init seems to indicate TESSDATA_PREFIX should be taken into account in practice I see exactly the getTessdataPrefix concatenated with ocrLanguage being used.
Let me know if I overlooked something
My environement
tesseract 4.0.0-beta.1
leptonica-1.75.3
libjpeg 9c : libpng 1.6.34 : libtiff 4.0.9 : zlib 1.2.11
Found AVX2
Found AVX
Found SSE
opencv-2.4.13.6
alpr --version
alpr version: 2.3.0
OS X 10.13.3
I have the same issue. Tried to export the TESSDATA_PREFIX to the correct path and it changed nothing when i reran tesseract. It's not taking the environment variable into account at all.
I'm on Ubuntu 16.04 and I compiled from source and now have the following:
tesseract 4.0.0-beta.1-53-g3fcb
leptonica-1.76.0
libjpeg 8d (libjpeg-turbo 1.4.2) : libpng 1.2.54 : libtiff 4.0.6 : zlib 1.2.8
Found AVX2
Found AVX
Found SSE
Unable to fix the issue by the methods described, I copied /usr/share/openalpr/runtime_data/ocr/tessdata/*.traineddata into /usr/share/openalpr/runtime_data/ocr/ and it seems to have corrected the problem. This is probably not recommended, and YMMV.
I have the same problem in Kubuntu 18.04
After following the official instructions for installing the package on an Ubuntu machine (Easy Way), running the install test, I've get this error
alpr lp.jpg
Error opening data file /usr/share/openalpr/runtime_data/ocr/lus.traineddata
Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory.
Failed loading language 'lus'
Tesseract couldn't load any languages!
Segmentation fault (core dumped)
After the penultimate line it takes a long time (aprox 10 seconds) and Ubuntu crashes:
Sorry, Ubuntu 18.04 has experienced an internal error.
If you notice further problems, try restarting the computer
The log can be seen here or:
alpr_crash_apport_log.txt
Tesseract version:
tesseract 4.0.0-beta.1
leptonica-1.75.3
libgif 5.1.4 : libjpeg 8d (libjpeg-turbo 1.5.2) : libpng 1.6.34 : libtiff 4.0.9 : zlib 1.2.11 : libwebp 0.6.1 : libopenjp2 2.3.0
Found AVX2
Found AVX
Found SSE
Marked as closed, unsure of recommended workaround on Ubuntu 18.04. Manual install w/build from latest sources?
Below path correction solved the problem for me,
export TESSDATA_PREFIX=/usr/share/openalpr/runtime_data/ocr/
tesseract version
tesseract 3.02.02
leptonica-1.78.0
libjpeg 8d (libjpeg-turbo 1.4.2) : libpng 1.2.54 : libtiff 4.0.6 : zlib 1.2.8
Kindly follow this link
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=907831
Make sure you in the /usr/share/openalpr/runtime_data/ocr directory and run sudo ln -s tessdata/* .
It works for me
sudo cp -a /usr/share/openalpr/runtime_data/ocr/tessdata/*.traineddata /usr/share/openalpr/runtime_data/ocr/
It works for me :)
Most helpful comment
sudo cp -a /usr/share/openalpr/runtime_data/ocr/tessdata/*.traineddata /usr/share/openalpr/runtime_data/ocr/It works for me :)