EasyPR是一款開源的中文車牌識別系統,項目地址。
在搭建的過程中,主要的問題是注意版本的兼容性,這里面的版本包括:opencv版本,g++版本以及cmake版本。
我使用的EasyPr版本信息如下:
commit 569e7642c2342a31e4358831597f1bedf23258bc Merge: b88966b eb54c4c Author: liuruoze <liuruoze@163.com> Date: Thu Jan 14 21:59:19 2016 +0800 Merge branch 'micooz-master'
使用的Cmake版本為,
[root@localhost EasyPR]# cmake --version cmake version 3.5.2 CMake suite maintained and supported by Kitware (kitware.com/cmake).
opencv的版本為:
[root@localhost EasyPR]# ll /usr/opt/opencv-3.0.0 total 480 drwxr-xr-x. 15 root root 4096 Jun 4 2015 3rdparty drwxr-xr-x. 6 root root 4096 May 24 11:16 apps drwxr-xr-x. 2 root root 4096 May 24 12:39 bin drwxr-xr-x. 5 root root 4096 Jun 4 2015 cmake -rw-r--r--. 1 root root 165737 May 24 11:16 CMakeCache.txt drwxr-xr-x. 10 root root 4096 May 24 12:39 CMakeFiles -rw-r--r--. 1 root root 4858 May 24 11:16 cmake_install.cmake -rw-r--r--. 1 root root 55335 Jun 4 2015 CMakeLists.txt -rw-r--r--. 1 root root 1144 May 24 11:16 cmake_uninstall.cmake -rw-r--r--. 1 root root 6472 May 24 11:16 CPackConfig.cmake -rw-r--r--. 1 root root 6821 May 24 11:16 CPackSourceConfig.cmake -rw-r--r--. 1 root root 3710 May 24 11:16 cvconfig.h drwxr-xr-x. 8 root root 4096 May 24 11:16 data drwxr-xr-x. 6 root root 4096 May 24 11:16 doc drwxr-xr-x. 5 root root 4096 May 24 11:16 include -rw-r--r--. 1 root root 12909 May 24 12:39 install_manifest.txt drwxr-xr-x. 2 root root 4096 May 24 10:56 junk drwxr-xr-x. 2 root root 4096 May 24 12:38 lib -rw-r--r--. 1 root root 2224 Jun 4 2015 LICENSE -rw-r--r--. 1 root root 101350 May 24 11:16 Makefile drwxr-xr-x. 38 root root 4096 May 24 11:16 modules drwxr-xr-x. 2 root root 4096 May 24 11:16 opencv2 -rw-r--r--. 1 root root 16391 May 24 11:16 OpenCVConfig.cmake -rw-r--r--. 1 root root 376 May 24 11:16 OpenCVConfig-version.cmake -rw-r--r--. 1 root root 11454 May 24 11:16 OpenCVModules.cmake drwxr-xr-x. 8 root root 4096 Jun 4 2015 platforms -rw-r--r--. 1 root root 636 Jun 4 2015 README.md drwxr-xr-x. 13 root root 4096 Jun 4 2015 samples drwxr-xr-x. 2 root root 4096 May 24 11:16 unix-install -rw-r--r--. 1 root root 6961 May 24 11:16 version_string.tmp
g++版本為:
[root@localhost EasyPR]# g++ --version g++ (GCC) 4.8.2 20140120 (Red Hat 4.8.2-15) Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
二. 與版本相關的問題
2.1 GCC版本問題
在centos 6.5上,Gcc的版本為
[root@n122 ~]# gcc --version gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
這個版本不能夠完整的支持C++11的標准,所以需要對其進行升級,使用如下命令:
wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo sudo yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++
執行完這兩條命令后,會在/opt/rh目錄下有GCC 4.8.2的新版本,這個時候系統的gcc仍然是老版本的,需要將系統的gcc進行替換,首先將/usr/bin下老版本的gcc都備份一下,
然后使用ln –s命令進行符號鏈接(例如gcc: ln –s /opt/rh/devtoolset-2/root/usr/bin/gcc /usr/bin/gcc ,其他以此類推)
lrwxrwxrwx. 1 root root 37 May 24 14:08 /usr/bin/c++ -> /opt/rh/devtoolset-2/root/usr/bin/c++ lrwxrwxrwx. 1 root root 37 May 24 13:34 /usr/bin/cpp -> /opt/rh/devtoolset-2/root/usr/bin/cpp lrwxrwxrwx. 1 root root 37 May 24 13:33 /usr/bin/gcc -> /opt/rh/devtoolset-2/root/usr/bin/gcc
為了使用的方便,/etc/profile下也做了如下修改:
export CC=/opt/rh/devtoolset-2/root/usr/bin/gcc export CPP=/opt/rh/devtoolset-2/root/usr/bin/cpp export CXX=/opt/rh/devtoolset-2/root/usr/bin/c++
2.2 Cmake版本問題
同樣centos 6.5上的cmake版本也太過老舊,不能夠直接用來編譯EasyPR,需要進行更新。
到camke的官網上進行下載,地址。這是一個腳本,下載完后,直接執行就行,然后將其添加到/etc/profile中,如下:
export PATH=$PATH:/data/zjc/soft_bk/cmake-3.5.2-Linux-x86_64/bin
2.3 opencv的版本問題
opecv我是使用3.0.0的版本,因為看到了如下的鏈接:
https://github.com/liuruoze/EasyPR/issues/102
從官網down下來opencv3.0.0.zip文件后,需要將opencv3.0.0編譯、安裝好,具體做法是:
切換到opencv3.0.0的目錄,執行cmake CMakeLists.txt, 然后執行make –j 12 && make install。 安裝完成。
在make的過程中,可能出現,ippicv_linux_20141027.tar.gz md5值不一致的情況
opencv-3.0.0/3rdparty/ippicv/downloads/linux-8b449a536a2157bcad08a2b9f266828b/ippicv_linux_20141027.tgz] expected hash: [8b449a536a2157bcad08a2b9f266828b] actual hash: [0103b909e19ca9c6497a7ae696c16480]
這個時候,可以直接百度,將這個包下載下來,然后放到downloads路徑下就OK了。
三. EasyPR的編譯
EasyPR自身提供的build.sh文件不能夠直接使用,需要手動進行編譯。
首先,修改CmakeLists.txt
[root@localhost EasyPR]# pwd /data/zjc/CVS/EasyPR [root@localhost EasyPR]# emacs CMakeLists.txt
然后,將/data/zjc/CVS/EasyPR路徑下的_build和CMakeFiles兩個文件夾刪掉(rm –fr)
然后執行,cmake CmakeLists.txt
然后執行,make –j 12
最后,在EasyPR的上層目錄生成了demo文件,注意,不是在EasyPR目錄下生成的demo文件,然后把demo文件拷貝到 EasyPR路徑下,進行測試,測試命令如下:
./demo recognize -p resources/image/plate_recognize.jpg --svm resources/model/svm.xml --ann resources/model/ann.xml







