Installing OpenALPR

In this section, we will deploy OpenALPR on the Raspberry Pi. Since OpenALPR needs more space on disk, make sure your Raspberry has space. You may need to expand your storage size.

Before we install OpenALPR, we need to install some prerequisite libraries to ensure correct installation. Make sure your Raspberry Pi is connected to the internet. You can type these commands to install all prerequisite libraries:

    $ sudo apt-get update
    $ sudo apt-get upgrade
    $ sudo apt-get install autoconf automake libtool  
    $ sudo apt-get install libleptonica-dev  
    $ sudo apt-get install libicu-dev libpango1.0-dev libcairo2-dev  
    $ sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev  
    $ sudo apt-get install python-dev python-numpy libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev  
    $ sudo apt-get install libgphoto2-dev
    $ sudo apt-get install virtualenvwrapper  
    $ sudo apt-get install liblog4cplus-dev  
    $ sudo apt-get install libcurl4-openssl-dev
    $ sudo apt-get install autoconf-archive  

Once this is done, we should install the required libraries, such as Leptonica, Tesseract, and OpenCV. We will install them in the next few steps.

In this step, we'll install the Leptonica library. It's a library to perform image processing and analysis. You can get more information about the Leptonica library from the official website at http://www.leptonica.org. To install the library on the Raspberry Pi, we'll download the source code from Leptonica and then compile it. Right now, we'll install the latest version of the Leptonica library, version 1.74.1. You can use these commands:

    $ wget http://www.leptonica.org/source/leptonica-1.74.1.tar.gz
    $ gunzip leptonica-1.74.1.tar.gz
    $ tar -xvf leptonica-1.74.1.tar
    $ cd leptonica-1.74.1/
    $ ./configure
    $ make
    $ sudo make install  

This installation takes more time, so ensure all prerequisite libraries have been installed properly.

After installing the Leptonica library, we should install the Tesseract library. This library is useful for processing OCR images. We'll install the Tesseract library from its source code on https://github.com/tesseract-ocr/tesseract. The following is a list of commands to install the Tesseract library from source:

    $ git clone https://github.com/tesseract-ocr/tesseract
    $ cd tesseract/  
    $ ./autogen.sh 
    $ ./configure
    $ make -j2
    $ sudo make install  

This installation process takes time. After it is done, you also can install data training files for the Tesseract library using these commands:

    $ make training  
    $ sudo make training-install  

The last required library to install OpenALPR is OpenCV. It's a famous library for computer vision. In this scenario, we will install OpenCV from source. It takes up more space on disk, so your Raspberry Pi disk should have enough free space. For demonstration, we'll install the latest OpenCV library. Version 3.2.0 is available on https://github.com/opencv/opencv. You can find the contribution modules on https://github.com/opencv/opencv_contrib. We also need to install modules with the same version as our OpenCV version.

First, we'll download and extract the OpenCV library and its modules. Type these commands:

    $ wget https://github.com/opencv/opencv/archive/3.2.0.zip
    $ mv 3.2.0.zip opencv.zip
    $ unzip opencv.zip
    $ wget https://github.com/opencv/opencv_contrib/archive/3.2.0.zip
    $ mv 3.2.0.zip opencv_contrib.zip
    $ unzip opencv_contrib.zip  

Now we'll build and install OpenCV from source. Navigate your Terminal to the folder where the OpenCV library was extracted. Let's suppose our OpenCV contribution module has been installed at ~/Downloads/opencv_contrib-3.2.0/modules. You can change this based on where your OpenCV contribution module folder was extracted.

    $ cd opencv-3.2.0/
    $ mkdir build
    $ cd build/
    $ cmake -D CMAKE_BUILD_TYPE=RELEASE 
        -D CMAKE_INSTALL_PREFIX=/usr/local 
        -D INSTALL_PYTHON_EXAMPLES=ON 
        -D OPENCV_EXTRA_MODULES_PATH=~/Downloads/opencv_contrib-3.2.0/modules 
        -D BUILD_EXAMPLES=ON ..
    $ make
    $ sudo make install
    $ sudo ldconfig  

This installation takes a while. It may take over two hours. Make sure there is no error in the installation process.

Finally, we'll install OpenALPR from source:

    $ git clone https://github.com/openalpr/openalpr.git
    $ cd openalpr/src/
    $ cmake ./
    $ make
    $ sudo make install
    $ sudo ldconfig  

After all this is installed, you are ready for testing. If it's not, resolve your errors before moving to the testing section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.76.7