open ALPR installation on Pi3

started with jessie lite 2017-04-10 raspbian

source:https://blog.vinczejanos.info/2016/08/31/install-openalpr-on-raspberry-pi-3/

after wrote the image into a 16GB uSD, first I do:
started 16:43
sudo apt-get update      
sudo apt-get upgrade       tooks very long time

necessary packages:



sudo 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 libpng12-dev libtiff5-dev libjasper-dev libdc1394-22-dev virtualenvwrapper liblog4cplus-dev libcurl4-openssl-dev

started 1727, with a lot of stuff to be installed, it got 232 files from met....
finally done at 1755

There is a change that it can't find certain packages due to  version difference, we can use
apt-cache search ....
 to find the exact version and then install it. But if you read the output message, then you will see the recommendation on the version...
now goes for

Leptonica, Tesseract, openCV and Install OpenALPR

reference page: there is also a part one, it's important to read part 1 also
https://blog.vinczejanos.info/2017/05/01/install-openalpr-on-raspberry-pi-3-part-2/

The key is to install the right version of each....Not always the latest one works....

tesseract 3.04.01, leptonica-1.71, openCV2.4.13

Leptonica is a library support for image processing and analysis...
http://www.leptonica.org/
Tessercat is a OCR engine
https://github.com/tesseract-ocr/tesseract/


  • Install Leptonica
sudo wget http://www.leptonica.org/source/leptonica-1.71.tar.gz
sudo tar xf leptonica-1.71.tar.gz  

started 18:04
cd /usr/src/leptonica-1.71
./configure
make  
make install  
seems fine at 18:37, 30 mins is not the longest one...you will see...


  • Install Tesseract
start with these package
apt-get install ca-certificates git  
apt-get install autoconf automake libtool  
apt-get install autoconf-archive  
apt-get install pkg-config  
the first 2 was installed already...
so installed autoconf-archive and pcg-config

for training tools, also needs:
apt-get install libicu-dev  
apt-get install libpango1.0-dev  
apt-get install libcairo2-dev  
above 3 are all installed...
Clone From GIT


cd /usr/src  
git clone https://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  

the make command takes about an hour....go for something...

finally, I tried to test:
/usr/src/tesseract# tesseract -v 

it comes an error:
tesseract: error while loading shared libraries: libtesseract.so.3: cannot open shared object file: No such file or directory  
according to part 1, I should do a ldconfig

test again, it's all good...
tesseract 3.04.01, leptonica-1.71....

now go for openCV


  • Install OpenCV
Download and extract:
cd /usr/src  
wget https://github.com/opencv/opencv/archive/2.4.13.zip  
unzip  2.4.13.zip  

then compile again
Compile:
cd opencv-2.4.13  
mkdir release  
cd release  
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..  
make  
make install  
this make took 2 hrs to make.....
  • Install OpenALPR
  • https://github.com/openalpr/openalpr
Download
cd /usr/src  
git clone https://github.com/openalpr/openalpr.git  
Build:
cd openalpr/src  
mkdir build  
cd build  
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc ..  
make  
make install  
According to part2, it says:"If you experience some errors please try to install these packages:"
What I did is to install all of them...
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/  
 beanstalkd and openjdk-7-jdk is added, tooks an hour for jdk....
after all done....
Test:
wget http://plates.openalpr.com/h786poj.jpg -O lp.jpg  
alpr lp.jpg  
root@raspberrypi:/usr/src/openalpr/src/build# alpr lp.jpg
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
which is good...


Open ALPR usage

user@linux:~/openalpr$ alpr --help

USAGE: 

   alpr  [-c <country_code>] [--config <config_file>] [-n <topN>] [--seek
         <integer_ms>] [-p <pattern code>] [--clock] [-d] [-j] [--]
         [--version] [-h] <image_file_path>


Where: 

   -c <country_code>,  --country <country_code>
     Country code to identify (either us for USA or eu for Europe). 
     Default=us

   --config <config_file>
     Path to the openalpr.conf file

   -n <topN>,  --topn <topN>
     Max number of possible plate numbers to return.  Default=10

   --seek <integer_ms>
     Seek to the specified millisecond in a video file. Default=0

   -p <pattern code>,  --pattern <pattern code>
     Attempt to match the plate number against a plate pattern (e.g., md
     for Maryland, ca for California)

   --clock
     Measure/print the total time to process image and all plates. 
     Default=off

   -d,  --detect_region
     Attempt to detect the region of the plate image.  [Experimental] 
     Default=off

   -j,  --json
     Output recognition results in JSON format.  Default=off

   --,  --ignore_rest
     Ignores the rest of the labeled arguments following this flag.

   --version
     Displays version information and exits.

   -h,  --help
     Displays usage information and exits.

   <image_file_path>
     Image containing license plates



In total, it took me about 7hrs.....good luck...

留言

這個網誌中的熱門文章

Heltec ESP32+OLED+Lora, hardware testing

micro SD card for ESP32, on lolin32 with OLED and heltec 32 lora oled

Install Network Time Protocol(NTP) on BeagleBone with Angstrom linux and set local time zone