This is a slightly modified update to Daniel Kornev's excellent post which goes into more detail about why building from source is necessary on 18.04. His post was missing a few dependencies that I didn't have installed namely cmake
, opencv
and pkg-config
. The following steps should get you a working build of openalpr
on a fresh install of Ubuntu 18.04.
If you're not working with a fresh install, this might be a good time to clean and update your system before proceeding. (Optional)
$ sudo apt update #fetch list of available updates
$ sudo apt upgrade #install updates – does not remove packages
$ sudo apt autoremove #removes unused/outdated packages
1. Remove any previously installed versions of Tesseract & Leptonica and install all required dependencies and build tools.
# remove any tesseract binaries and languages
$ sudo apt-get remove tesseract-ocr*
# remove any previously installed leptonica
$ sudo apt-get remove libleptonica-dev
# make sure other dependencies are removed too
$ sudo apt-get autoclean
$ sudo apt-get autoremove --purge
# install libtool m4 automake cmake & pkg-config
$ sudo apt-get install libtool m4 automake cmake pkg-config
# install opencv
$ sudo apt-get install libopencv-dev
# install liblog4cplus-dev, liblog4cplus-1.1-9 and build-essential:
$ sudo apt-get install liblog4cplus-1.1-9 liblog4cplus-dev build-essential
$ wget https://github.com/DanBloomberg/leptonica/archive/1.74.1.tar.gz
# unpack tarball and cd into leptonica directory
$ tar -xvzf 1.74.1.tar.gz
$ cd leptonica-1.74.1
# build leptonica
$ ./autobuild
$ ./configure
$ sudo make
$ sudo make install
$wget https://github.com/tesseract-ocr/tesseract/archive/3.05.02.tar.gz
# unpack tarball and cd into tesseract directory
$ tar -xvzf
$ cd tesseract-3.05.02/
# build tesseract
$ ./autogen.sh
$ ./configure --enable-debug LDFLAGS="-L/usr/local/lib" CFLAGS="-I/usr/local/include"
$ sudo make
$ sudo make install
$ sudo make install-langs
$ sudo ldconfig
# check everything worked
$ tesseract --version
# you should see
tesseract 3.05.02
leptonica-1.74.1
$ sudo add-apt-repository ppa:xapienz/curl34
$ sudo apt-get update
$ sudo apt-get install libcurl4 libcurl4-openssl-dev
$ git clone https://github.com/openalpr/openalpr.git
$ cd openalpr/src
$ mkdir build
$ cd build
# setup the compile environment
$ cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc ..
# and compile the library
$ make && sudo make install
$ wget http://plates.openalpr.com/h786poj.jpg -O lp.jpg
$ alpr lp.jpg
# if everything worked you should see:
plate0: 10 results
- 786P0 confidence: 89.6593
- 786PO confidence: 85.9889
- 786PQ confidence: 85.8115
- 786PD confidence: 85.7408
- 786PG confidence: 84.4258
- 786P confidence: 83.0879
- 7B6P0 confidence: 72.5012
- 7B6PO confidence: 68.8309
- 7B6PQ confidence: 68.6534
- 7B6PD confidence: 68.5827