Compilation instructions (Ubuntu Linux)

Sleeba Paul edited this page Apr 19, 2018 · 27 revisions

The Easiest Way

(Ubuntu 16.04)

sudo apt-get update && sudo apt-get install -y openalpr openalpr-daemon openalpr-utils libopenalpr-dev

Test the library

alpr -c us ea7the.jpg

alpr -c eu h786poj.jpg

The Easy Way

(Ubuntu 14.04+)

# Install prerequisites
sudo apt-get install libopencv-dev libtesseract-dev git cmake build-essential libleptonica-dev
sudo apt-get install liblog4cplus-dev libcurl3-dev

# If using the daemon, install beanstalkd
sudo apt-get install beanstalkd

# Clone the latest code from GitHub
git clone

# Setup the build directory
cd openalpr/src
mkdir build
cd build

# setup the compile environment

# compile the library

# Install the binaries/libraries to your local system (prefix is /usr)
sudo make install

# Test the library
wget -O lp.jpg
alpr lp.jpg

The Harder Way (Compile all dependencies manually)

  1. Make sure that dependencies and required tools are installed
  • sudo apt-get install --assume-yes libpng12-dev libjpeg62-dev libtiff4-dev zlib1g-dev
  • sudo apt-get install --assume-yes build-essential
  • sudo apt-get install --assume-yes autoconf automake libtool
  • sudo apt-get install --assume-yes git-core
  • sudo apt-get install --assume-yes cmake
  1. install opencv (tutorial)
  1. download and install leptonica and tesseract-ocr
  1. unpack the tarballs:
  • tar xf /usr/local/src/openalpr/tesseract-ocr-3.02.02.tar.gz
  • tar xf /usr/local/src/openalpr/tesseract-ocr-3.02.eng.tar.gz
  • tar xf /usr/local/src/openalpr/leptonica-1.70.tar.gz
  1. compile leptonica:
  • cd /usr/local/src/openalpr/leptonica-1.70/
  • ./configure --prefix=/usr/local
  • make
  • make install
  1. compile tesseract:
  • cd /usr/local/src/openalpr/tesseract-ocr/
  • ./
  • ./configure
  • make
  • sudo make install
  • sudo ldconfig
  1. clone the openalpr repo to /usr/local/src/openalpr/ directory
  1. update CMakeLists.txt compile openalpr
  • cd /usr/local/src/openalpr/openalpr/
  • gedit CMakeLists.txt &
    • SET(OpenCV_DIR "/usr/local/lib")
    • SET(Tesseract_DIR "/usr/local/src/openalpr/tesseract-ocr")
  • cmake ./
  • make

Note: For Tesseract 3.03 the source files can be downloaded from the main svn branch or

A README to real-time license plate detection with OpenALPR, OpenCV and Python

There are many things which could go possibly wrong if we slightly move in a different direction while installing this package. Follow these instructions for Ubuntu machines to scale this package for real-time detection with OpenCV and Python. (Mac HomeBrew is broken too but above the scope of this answer)

  1. Start from a clean state, remove every apt-package you've installed for openaplr if you've already messed it up. Remove the python binding, if you've set up that too.
apt list --installed | grep alpr
sudo apt-get purge libopenalpr
sudo rm -rf /usr/local/lib/python3.5/dist-packages/openalpr*
  1. Follow the official instructions for installing the package on an Ubuntu machine here. Now, this is the catch. Don't follow The Easiest Way described. Follow the The Easy Way (Ubuntu 14.04+). Because, the version which The Easiest Way provides is an older one, which doesn't support recognize_ndarray functionality for python bindings.

  2. Once you've completed the steps, go to the git repo you've cloned to your machine during the above installation and install the python bindings. runtime_data folder is also available in this repo, which will be helpful for next step.

cd openalpr/src/bindings/python/
sudo python3 install
  1. While declaring the Alpr object in the script, what they actually meant by
alpr = Alpr("us", "/path/to/openalpr.conf", "/path/to/runtime_data")


alpr = Alpr("us", "/etc/openalpr/openalpr.conf", "openalpr/runtime_data/")

  1. Now you're all set to grab a video or webcam using cv2.VideoCapture(), feed each frame to alpr.recognize_ndarray() and life is good 💯
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.