CentOS 6.5 EasyPR环境搭建

时间:2022-11-29 16:54:02

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都备份一下,

CentOS 6.5 EasyPR环境搭建

然后使用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

CentOS 6.5 EasyPR环境搭建

从官网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

CentOS 6.5 EasyPR环境搭建

然后,将/data/zjc/CVS/EasyPR路径下的_build和CMakeFiles两个文件夹删掉(rm –fr)

CentOS 6.5 EasyPR环境搭建

然后执行,cmake CmakeLists.txt

然后执行,make –j 12

CentOS 6.5 EasyPR环境搭建

最后,在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环境搭建

CentOS 6.5 EasyPR环境搭建

CentOS 6.5 EasyPR环境搭建