在樹莓派3安裝 OpenALPR

在樹莓派3安裝 OpenALPR

資料來源 httpsss://blog.vinczejanos.info/2017/05/01/install-openalpr-on-raspberry-pi-3-part-2/ 但是有問題,所以修改並紀錄如下

Install OpenALPR

  • Install the dependencies
apt-get install autoconf automake libtool libleptonica-dev libicu-dev libpango1.0-dev libcairo2-dev cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev python-dev python-numpy libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev virtualenvwrapper liblog4cplus-dev libcurl4-openssl-dev  

This part comes from my old post: Install OpenALPR on Raspberry PI 3

  • Install Leptonica
cd /usr/src  
wget httpss://www.leptonica.org/source/leptonica-1.71.tar.gz  
tar xf leptonica-1.71.tar.gz  

You may need to install these packages:

apt-get install libjpeg-dev libtiff5-dev libpng12-dev gcc make  

Compile:

cd /usr/src/leptonica-1.71
./configure
make  
make install  
  • Install Tesseract

You also may need to install these packages:

apt-get install ca-certificates git  
apt-get install autoconf automake libtool  
apt-get install autoconf-archive  
apt-get install pkg-config  

If you plan to install the training tools, you also need the following libraries:

apt-get install libicu-dev  
apt-get install libpango1.0-dev  
apt-get install libcairo2-dev  

Clone From GIT

cd /usr/src  
git clone httpsss://github.com/tesseract-ocr/tesseract.git  

Check available versions (tags)

cd /usr/src/tesseract  
git tag  

Checkout the version which we need:

git checkout 3.04.01  

Run these commands:

# cd /usr/src/tesseract  
# ./autogen.sh
# ./configure --enable-debug
# make  
# make install  

# sudo ldconfig


You will get the appropriate version:

root@openalpr-tst01:/usr/src/tesseract# tesseract -v  
tesseract 3.04.01  
 leptonica-1.71
  libjpeg 6b : libpng 1.2.50 : libtiff 4.0.3 : zlib 1.2.8

  • Install OpenCV

Download and extract:

cd /usr/src  
wget httpsss://github.com/opencv/opencv/archive/2.4.13.zip  
unzip  2.4.13.zip  

Compile:

# cd opencv-2.4.13  
# mkdir release  
# cd release  
# cmake -D CMAKE_BUILD_TYPE=RELEASE -D ENABLE_PRECOMPILED_HEADERS=OFF -D CMAKE_INSTALL_PREFIX=/usr/local .. 
# make 
# make install 
# export LD_LIBRARY_PATH=/usr/local/lib 
# sudo nano /etc/ld.so.conf.d/randomLibs.conf

inside the file you are supposed to write the complete path to the directory that contains all the libraries that you wish to add to the system, for example
/usr/local/lib 

#sudo ldconfig
Install OpenALPR

Download

# cd /usr/src  
# git clone httpsss://github.com/openalpr/openalpr.git  

Build:

# cd openalpr/src  
# mkdir build  
# cd build  
# cmake -D CMAKE_INSTALL_PREFIX:PATH=/usr -D CMAKE_INSTALL_SYSCONFDIR:PATH=/etc ..
# make  
# make install  

If you experience some errors please try to install these packages:

apt-get install cmake  
apt-get install liblog4cplus-dev libcurl3-dev  
sudo apt-get install beanstalkd  
apt-get install openjdk-7-jdk  
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64/  

Test:

wget httpss://plates.openalpr.com/h786poj.jpg -O lp.jpg  
alpr lp.jpg  

The result must be something like this (Without any errors):

plate0: 8 results  
    - 786P0      confidence: 90.1703
    - 786PO      confidence: 85.579
    - 786PQ      confidence: 85.3442
    - 786PD      confidence: 84.4616
    - 7B6P0      confidence: 69.4531
    - 7B6PO      confidence: 64.8618
    - 7B6PQ      confidence: 64.627
    - 7B6PD      confidence: 63.7444