Compilation instructions (Ubuntu Linux) - patilkunal/openalpr GitHub Wiki
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
wget http://plates.openalpr.com/ea7the.jpg
alpr -c us ea7the.jpg
wget http://plates.openalpr.com/h786poj.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 https://github.com/openalpr/openalpr.git
# Setup the build directory
cd openalpr/src
mkdir build
cd build
# setup the compile environment
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc ..
# compile the library
make
# Install the binaries/libraries to your local system (prefix is /usr)
sudo make install
# Test the library
wget http://plates.openalpr.com/h786poj.jpg -O lp.jpg
alpr lp.jpg
The Harder Way (Compile all dependencies manually)
- 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
- install opencv (tutorial)
- download and install leptonica and tesseract-ocr
-
tesseract-ocr requires leptonica and at least one language package.
-
https://github.com/tesseract-ocr/tesseract/archive/3.02.02.tar.gz (Rename to tesseract-ocr-3.02.02.tar.gz)
-
https://sourceforge.net/projects/tesseract-ocr-alt/files/tesseract-ocr-3.02.eng.tar.gz
-
move the downloaded tarballs to some directory. I will assume that they are located at /usr/local/src/openalpr/.
- 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
- compile leptonica:
- cd /usr/local/src/openalpr/leptonica-1.70/
- ./configure --prefix=/usr/local
- make
- make install
- compile tesseract:
- cd /usr/local/src/openalpr/tesseract-ocr/
- ./autogen.sh
- ./configure
- make
- sudo make install
- sudo ldconfig
- clone the openalpr repo to /usr/local/src/openalpr/ directory
- cd /usr/local/src/openalpr/
- git clone https://github.com/openalpr/openalpr.git
- 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 https://drive.google.com/folderview?id=0B7l10Bj_LprhQnpSRkpGMGV2eE0&usp=sharing#list.
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)
- 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*
-
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 theThe Easy Way (Ubuntu 14.04+)
. Because, the version whichThe Easiest Way
provides is an older one, which doesn't supportrecognize_ndarray
functionality for python bindings. -
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 setup.py install
- While declaring the
Alpr
object in the script, what they actually meant by
alpr = Alpr("us", "/path/to/openalpr.conf", "/path/to/runtime_data")
is
alpr = Alpr("us", "/etc/openalpr/openalpr.conf", "openalpr/runtime_data/")
- Now you're all set to grab a video or webcam using
cv2.VideoCapture()
, feed each frame toalpr.recognize_ndarray()
and life is good 💯