標籤:
EasyPR是一款開源的中文車牌識別系統,項目地址。
在搭建的過程中,主要的問題是注意版本的相容性,這裡面的版本包括:opencv版本,g++版本以及cmake版本。
我使用的EasyPr版本資訊如下:
commit 569e7642c2342a31e4358831597f1bedf23258bcMerge: b88966b eb54c4cAuthor: liuruoze <[email protected]163.com>Date: Thu Jan 14 21:59:19 2016 +0800 Merge branch ‘micooz-master‘
使用的Cmake版本為,
[[email protected] EasyPR]# cmake --versioncmake version 3.5.2CMake suite maintained and supported by Kitware (kitware.com/cmake).
opencv的版本為:
[[email protected] EasyPR]# ll /usr/opt/opencv-3.0.0total 480drwxr-xr-x. 15 root root 4096 Jun 4 2015 3rdpartydrwxr-xr-x. 6 root root 4096 May 24 11:16 appsdrwxr-xr-x. 2 root root 4096 May 24 12:39 bindrwxr-xr-x. 5 root root 4096 Jun 4 2015 cmake-rw-r--r--. 1 root root 165737 May 24 11:16 CMakeCache.txtdrwxr-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.hdrwxr-xr-x. 8 root root 4096 May 24 11:16 datadrwxr-xr-x. 6 root root 4096 May 24 11:16 docdrwxr-xr-x. 5 root root 4096 May 24 11:16 include-rw-r--r--. 1 root root 12909 May 24 12:39 install_manifest.txtdrwxr-xr-x. 2 root root 4096 May 24 10:56 junkdrwxr-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 Makefiledrwxr-xr-x. 38 root root 4096 May 24 11:16 modulesdrwxr-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.cmakedrwxr-xr-x. 8 root root 4096 Jun 4 2015 platforms-rw-r--r--. 1 root root 636 Jun 4 2015 README.mddrwxr-xr-x. 13 root root 4096 Jun 4 2015 samplesdrwxr-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++版本為:
[[email protected] EasyPR]# g++ --versiong++ (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 NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
二. 與版本相關的問題
2.1 GCC版本問題
在centos 6.5上,Gcc的版本為
[[email protected] ~]# gcc --versiongcc (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 NOwarranty; 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.reposudo 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/cpplrwxrwxrwx. 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/cppexport 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
[[email protected] EasyPR]# pwd/data/zjc/CVS/EasyPR[[email protected] 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
CentOS 6.5 EasyPR環境搭建