2016年2月17日 星期三

[Openalpr] How to compile openalpr for Mac?


I try to compile openalpr on my MacBook Pro. Below is the note.


0. Test environment
  • OS X EI Capitan (v10.11.2)
  • tesseract v3.0.4
  • openalpr v2.2.0
  • opencv v3.0.0

1. Download source
$ git clone https://github.com/openalpr/openalpr.git$ cd openalpr/src
$ mkdir build
$ cd build

$ wget http://www.leptonica.com/source/leptonica-1.73.tar.gz
$ tar xvf leptonica-1.73.tar.gz
$ cd leptonica-1.73
$ ./configure CC=/usr/bin/clang
$ make
$ sudo make install 
$ cd ~/openalpr
$ git clone https://github.com/tesseract-ocr/tesseract.git tesseract-ocr
$ cd tesseract-ocr/
$ git tag -l $ git checkout tags/3.04.00
$ ./autogen.sh
$ ./configure CXX=/usr/bin/clang++ --with-extra-includes=/usr/local/include --with-extra-libraries=/usr/local/lib
$ make
$ sudo make install

3. Install OpenCV, I used OpenCV v3.0.0 that I already installed.
http://albert-oma.blogspot.tw/2015/08/how-to-install-opencv-in-mac-os.html

4. Install openalpr
$ cmake .. -DCMAKE_INSTALL_PREFIX:PATH=/usr/local -DCMAKE_INSTALL_SYSCONFDIR:PATH=/etc -DCMAKE_MACOSX_RPATH=true
$ make
$ sudo make install

5. Test
$ wget http://i.imgur.com/pjukRD0.jpg -O lp.jpg
$ alpr lp.jpg

FAQ:
1. Compile error about "undeclared identifier 'ENTER_KEY_ONE' and 'ENTER_KEY_TWO'"Referece
 https://github.com/openalpr/openalpr/blob/master/src/misc_utilities/classifychars.cpp, you will find these 2 definitions are missing for __APPLE__ platform. So you need just add below 2 lines, and it will pass the compilation.
const int ENTER_KEY_ONE = 13;
const int ENTER_KEY_TWO = 10;
2. How to generate test license plate images?
method1. download from here.
method2. use openalpr deamon to capture from a real camera or streaming server.