首页 技术 正文
技术 2022年11月23日
0 收藏 679 点赞 3,498 浏览 44491 个字

http://blog.csdn.NET/daunxx/article/details/50506625

转载注释:有些包名和系统包名并不匹配,yum install 找不到的时候,可以yum search一下。比如gtk2-devel和gstreamer-plugins-base-devel

<code class="hljs ruby has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;"><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@time</span> <span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span> <span class="hljs-constant" style="box-sizing: border-box;">Jan</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">13</span>,<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2016</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">20</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">29</span> <span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@author</span> <span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span> duanxxnj<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@163</span>.com</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>
花了两天时间才把Openv3.1的Python安装完成。
中间遇到了好多奇怪的错误,在这里记录下整个安装过程。

系统环境

<code class="hljs ruby has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">[<span class="hljs-constant" style="box-sizing: border-box;">Duanxx</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@CentOS</span> ~]<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>uname -a <span class="hljs-constant" style="box-sizing: border-box;">Linux</span> <span class="hljs-constant" style="box-sizing: border-box;">CentOS</span>.<span class="hljs-constant" style="box-sizing: border-box;">Duanxx</span> <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3.10</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">327.3</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>.el7.x86_64 <span class="hljs-comment" style="color: rgb(136, 0, 0); box-sizing: border-box;">#1 SMP Wed Dec 9 14:09:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux</span> [<span class="hljs-constant" style="box-sizing: border-box;">Duanxx</span><span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">@CentOS</span> ~]<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$ </span>cat /etc/centos-release <span class="hljs-constant" style="box-sizing: border-box;">CentOS</span> <span class="hljs-constant" style="box-sizing: border-box;">Linux</span> release <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7.2</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1511</span> (<span class="hljs-constant" style="box-sizing: border-box;">Core</span>) </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul>

软件源安装

EPEL

主页 
下载EL7后面的数据源即可

<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">sudo rpm <span class="hljs-attribute" style="box-sizing: border-box;">-ivh</span> epel<span class="hljs-attribute" style="box-sizing: border-box;">-release</span><span class="hljs-attribute" style="box-sizing: border-box;">-latest</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">-</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7.</span>noarch<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>rpm</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

nux-dextop

主页 
下载el7的数据源

<code class="hljs avrasm has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">sudo rpm -ivh nux-dextop-release-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5.</span>el7<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.nux</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.noarch</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.rpm</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

ELRepo

主页

<code class="hljs avrasm has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">rpm --import https://www<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.elrepo</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.org</span>/RPM-GPG-KEY-elrepo<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.org</span> rpm -Uvh http://www<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.elrepo</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.org</span>/elrepo-release-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7.0</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.</span>el7<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.elrepo</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.noarch</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.rpm</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

基本准备

<code class="hljs bash has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;"><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> yum update</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">sudo yum install autoconf automake cmake freetype<span class="hljs-attribute" style="box-sizing: border-box;">-devel</span> gcc gcc<span class="hljs-attribute" style="box-sizing: border-box;">-c</span><span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">++</span> git libtool make mercurial nasm pkgconfig zlib<span class="hljs-attribute" style="box-sizing: border-box;">-devel</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

安装cmake-gui

这里需要特别说明一下,这个是一定要安装的,等会编译的时候需要使用到它
<code class="hljs bash has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;"><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> yum install cmake-gui</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

为了支持GUI特征

<code class="hljs bash has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;"><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> yum install gtk2-devel</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

为了支持摄像头

<code class="hljs bash has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;"><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> yum install libdc1394-devel <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> yum install libv4l-devel</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

为了支持视频媒体

<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">sudo yum install ffmpeg<span class="hljs-attribute" style="box-sizing: border-box;">-devel</span> sudo yum install gstreamer<span class="hljs-attribute" style="box-sizing: border-box;">-plugins</span><span class="hljs-attribute" style="box-sizing: border-box;">-base</span><span class="hljs-attribute" style="box-sizing: border-box;">-devel</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

这里需要说明,ffmpeg其实最好是手动安装 
这里给出手动安装教程连接手动安装教程连接

顺便说一句,很多人都在抱怨Centos上无法看视频的问题。 
其实就是没有解码器。 
个人建议使用vlc这个开源的视频解码器。

<code class="hljs bash has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;"><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> yum install vlc</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

需要播放视频的时候,使用下面的命令即可

<code class="hljs avrasm has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">vlc name<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.mp</span>4</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

关于python

我的Python版本是当前最新2.7.11,集成在Anaconda中。 
个人感觉这个很好用,建议大家安装使用

因为Centos是自带pyhton的,所以需要将Anaconda的Python添加环境变量。

<code class="hljs avrasm has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">vim ~/<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.bashrc</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

在文件最后面添加:

<code class="hljs bash has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">PATH=<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"/usr/local/anaconda2/bin:<span class="hljs-variable" style="color: rgb(102, 0, 102); box-sizing: border-box;">$PATH</span>"</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">export</span> PATH</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

这样在使用python的时候用的就是Anaconda的python了。

ipp_icv下载

下载地址

这个东西是一个并行计算库,在编译的时候如果没有这货,就会编译不通过。 
虽然可以直接在命令中忽略这个,但个人建议还是用上比较好

可选的依赖项

上面的那些依赖如果安装完成后,就已经具备了安装Opencv的基本依赖了。
根据个人需要,可能还需要安装一些其他的依赖,下面给出一些可选的依赖项。

图形文件解码库更新

opencv自带了一些png/jpg等图片的解码器,但可能有一些老了。
可以使用一些比较新的图片解码库:
<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">sudo yum install libpng<span class="hljs-attribute" style="box-sizing: border-box;">-devel</span> sudo yum install libjpeg<span class="hljs-attribute" style="box-sizing: border-box;">-turbo</span><span class="hljs-attribute" style="box-sizing: border-box;">-devel</span> sudo yum install jasper<span class="hljs-attribute" style="box-sizing: border-box;">-devel</span> sudo yum install openexr<span class="hljs-attribute" style="box-sizing: border-box;">-devel</span> sudo yum install libtiff<span class="hljs-attribute" style="box-sizing: border-box;">-devel</span> sudo yum install libwebp<span class="hljs-attribute" style="box-sizing: border-box;">-devel</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li></ul>

线程构建模块

Intel’s Threading Building Blocks (TBB),是Intel公司开发的并行编程开发的工具。 
想要使用这个的话,在Cmake的时候,需要使用参数 -D WITH_TBB=ON

<code class="hljs bash has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;"><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> yum install tbb-devel</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

矩阵计算

Eigen是一个开源的C++矩阵计算工具 
想要使用这个的花,在Cmake的时候,需要使用参数 -D WITH_EIGEN=ON 
当然最好的安装方式是从源码安装,这里直接用yum安装了

<code class="hljs bash has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;"><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> yum install eigen3-devel</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

cuda安装

cuda是NVIDIA推出的通用并行计算架构,该架构使GPU能够解决复杂的计算问题。 
使用C语言来为CUDA™架构编写程序。

我的笔记本上只有Centos系统,并不是使用的虚拟机。 
如果是你使用的是虚拟机,就可以直接跳过这个了。

<code class="hljs avrasm has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">sudo rpm -ivh http://ftp-srv2<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.kddilabs</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.jp</span>/Linux/packages/fedora/epel/<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7</span>/x86_64/e/epel-release-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">5.</span>noarch<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.rpm</span> wget http://developer<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.download</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.nvidia</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.com</span>/compute/cuda/<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7</span>_0/Prod/local_installers/rpmdeb/cuda-repo-rhel7-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>-local-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7.0</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">28.</span>x86_64<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.rpm</span> sudo rpm -ivh cuda-repo-rhel7-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>-local-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">7.0</span>-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">28.</span>x86_64<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.rpm</span> sudo yum install cuda</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul>

Contrib modules

在opencv2.4中,opencv_contrib模块已经集成在了其中。
但是对于opencv3.1而言,由于这个模块中的代码相对不太稳定
它并没有集成在opencv3.1中。[下载连接](https://github.com/Itseez/opencv_contrib)
强烈建议安装opencv的时候也安装这个。
当然,现在可以不用安装,毕竟东西太多就会繁琐。
它的安装方式在github上有详细的说明。
如果想要安装,可直接参考,这里不做过多说明。

Opencv3.1编译安装

下载Opencv3.1

源码连接

<code class="hljs bash has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">unzip opencv-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3.1</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span>.zip <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">cd</span> opencv-<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">3.1</span>.<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0</span> mkdir build <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">cd</span> build</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul>

先Cmake一次

<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">cmake <span class="hljs-attribute" style="box-sizing: border-box;">-D</span> CMAKE_BUILD_TYPE<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span>RELEASE <span class="hljs-attribute" style="box-sizing: border-box;">-D</span> CMAKE_INSTALL_PREFIX<span class="hljs-subst" style="color: rgb(0, 0, 0); box-sizing: border-box;">=</span>/usr/<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">local</span> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">..</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

此时会发现Cmake停在了下面这个位置,直接用Ctrl+C停掉当前的Cmake

<code class="hljs haml has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">-<span class="ruby" style="box-sizing: border-box;">- checking <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">for</span> <span class="hljs-class" style="box-sizing: border-box;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">module</span> '<span class="hljs-title" style="box-sizing: border-box; color: rgb(102, 0, 102);">libgphoto2</span>'</span> </span>-<span class="ruby" style="box-sizing: border-box;">- package <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">'libgphoto2'</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">not</span> found </span>-<span class="ruby" style="box-sizing: border-box;">- <span class="hljs-constant" style="box-sizing: border-box;">ICV</span><span class="hljs-symbol" style="color: rgb(0, 102, 102); box-sizing: border-box;">:</span> <span class="hljs-constant" style="box-sizing: border-box;">Downloading</span> ippicv_linux_20151201.tgz...</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul>

进入下面这个文件夹,会发现ippicv_linux_20151201.tgz文件

<code class="hljs has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">opencv-3.1.0/3rdparty/ippicv/downloads/linux-808b791a6eac9ed78d32a7666804320e</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

用 rm ippicv_linux_20151201.tgz,删除这个文件。 
然后将上面ipp_icv下载中下载的文件放在这个文件夹下。

重新使用上面的命令Cmake一次。这一此Cmake可以通过,并且也可以作make擦作。 
但是,在Cmake提供的logout中可以看到下面这条信息:

<code class="hljs d has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">-- Found PythonInterp: /usr/local/anaconda2/bin/python2.7 (found suitable <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">version</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"2.7.11"</span>, minimum required <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">is</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"2.7"</span>) -- Could NOT find PythonLibs: Found unsuitable <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">version</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"2.7.5"</span>, but required <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">is</span> exact <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">version</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"2.7.11"</span> (found /lib64/libpython2.7.so) -- Could NOT find PythonInterp: Found unsuitable <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">version</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"2.7.11"</span>, but required <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">is</span> at least <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"3.4"</span> (found /usr/local/anaconda2/bin/python) -- Could NOT find PythonInterp: Found unsuitable <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">version</span> <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"2.7.11"</span>, but required <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">is</span> at least <span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"3.2"</span> (found /usr/local/anaconda2/bin/python)</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li></ul>

这里PythonInterp和PythonLibs都不符合,会导致Python的OpenCV库无法编译成功。 
但是C++的库是没有问题的。 
为了让OpenCV的Python库可以编译出来,需要做下面一步:

使用Cmake-gui

<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">cmake<span class="hljs-attribute" style="box-sizing: border-box;">-gui</span> <span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">..</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

在cmake-gui的界面中找到python的配置选项,并且设置如下: 
Opencv3.1+python2.7的CentOS7安装

大家可以按照自己的python环境来配置这些选项。

再按Configure,就会看到如下配置,这些配置必须要有。

<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;"> Python <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>: Interpreter: /usr/<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">local</span>/anaconda2/bin/python2<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.7</span> (ver <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.7</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.11</span>) Libraries: /usr/<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">local</span>/anaconda2/lib/libpython2<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.7</span><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">.</span>so (ver <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2.7</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.11</span>) numpy: /usr/<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">local</span>/anaconda2/lib/python2<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.7</span>/site<span class="hljs-attribute" style="box-sizing: border-box;">-packages</span>/numpy/core/include (ver <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1.10</span><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.1</span>) packages path: /usr/<span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">local</span>/anaconda2/lib/python2<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">.7</span>/site<span class="hljs-attribute" style="box-sizing: border-box;">-packages</span> </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li><li style="box-sizing: border-box; padding: 0px 5px;">4</li><li style="box-sizing: border-box; padding: 0px 5px;">5</li><li style="box-sizing: border-box; padding: 0px 5px;">6</li></ul>

再按一下Generate,完成后就可以退出cmake-gui了。

编译安装Opencv

make 编译,后面的参数 -j8 指的是我的cpu有8线程,这个提议提高编译的效率。 
大家需要根据自己的CPU的线程数来确定这个值。 
当然,直接make也没问题,就是慢一点而已。

<code class="hljs lasso has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">make <span class="hljs-attribute" style="box-sizing: border-box;">-j8</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

看到这两句,就说明编译成功,否则的话将上面cmke-gui的步骤再来一次。

<code class="hljs vbnet has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;">Linking CXX <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">shared</span> <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">module</span> ../../<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">lib</span>/cv2.so [<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">100</span>%] Built target opencv_python2</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

最后一行命令:

<code class="hljs bash has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;"><span class="hljs-built_in" style="color: rgb(102, 0, 102); box-sizing: border-box;">sudo</span> make install</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li></ul>

测试Opencv

在python的编辑器中写下面的代码,我用的编辑器是PyCharm,感觉很好用。

<code class="hljs python has-numbering" style="display: block; padding: 0px; background: transparent; color: inherit; box-sizing: border-box; font-family: "Source Code Pro", monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">import</span> cv2 <span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">print</span> cv2.__version__</code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px;  top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right: 1px solid rgb(221, 221, 221); list-style: none; text-align: right;"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul>

输出结果3.1.0,说明opencv的python版本,安装成功

上一篇: IE的变态
下一篇: 小试cordova
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,999
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,511
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,357
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,140
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848