[环境配置]Ubuntu 16.04 源码编译安装OpenCV-3.2.0+OpenCV_contrib-3.2.0及产生的问题
1.OpenCV-3.2.0+OpenCV_contrib-3.2.0编译安装过程
1)下载官方要求的依赖包
- GCC 4.4.x or later
- CMake 2.6 or higher
- Git
- GTK+2.x or higher, including headers (libgtk2.0-dev) # 控制opencv GUI
- pkg-config
- Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy)
- ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev
- [optional] libtbb2 libtbb-dev
- [optional] libdc1394 2.x
- [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev, libdc1394-22-dev
$ sudo apt-get install build-essential
$ sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
$ sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev # 处理图像所需的包
$ sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev liblapacke-dev
$ sudo apt-get install libxvidcore-dev libx264-dev # 处理视频所需的包
$ sudo apt-get install libatlas-base-dev gfortran # 优化opencv功能
$ sudo apt-get install ffmpeg
2)下载OpenCV-3.2.0+OpenCV_contrib-3.2.0
$ cd /the_path_you_would_install
$ wget https://github.com/opencv/opencv/archive/3.2.0.zip
$ wget https://github.com/opencv/opencv_contrib/archive/3.2.0.zip
直接右键解压,然后进行安装。
$ cd opencv-3.2.0
$ mkdir build
$ cd build
$ cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.2.0/modules/ ..
$ make -j8 #如果线程足够多可以使用 make -j12
$ sudo make install
第四行最后的 .. 一定不能忘记,因为我们是在/build文件夹中编译上层文件夹的程序。
$ sudo ldconfig -v
$ pkg-config --modversion opencv #确认OpenCV的版本,如果显示3.2.0说明安装完成
2.遇到的问题及解决方案
1)关于opencv_lapack.h缺失的问题
问题如下
In file included from /home/yao/opencv-3.2.0/modules/core/src/hal_internal.cpp:49:0:
/home/yao/opencv-3.2.0/build/opencv_lapack.h:2:45: fatal error: LAPACKE_H_PATH-NOTFOUND/lapacke.h: No such file or directory
compilation terminated.
modules/core/CMakeFiles/opencv_core.dir/build.make:114: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/src/hal_internal.cpp.o' failed
make[2]: *** [modules/core/CMakeFiles/opencv_core.dir/src/hal_internal.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs.... [ 27%] Built target pch_Generate_opencv_test_optflow
[ 27%] Built target pch_Generate_opencv_perf_optflow
[ 27%] Built target pch_Generate_opencv_test_phase_unwrapping
[ 27%] Built target pch_Generate_opencv_phase_unwrapping
[ 27%] Built target pch_Generate_opencv_test_stitching
[ 27%] Built target pch_Generate_opencv_test_structured_light
[ 27%] Built target pch_Generate_opencv_stitching
[ 27%] Built target pch_Generate_opencv_perf_stitching
[ 27%] Built target pch_Generate_opencv_structured_light
CMakeFiles/Makefile2:1901: recipe for target 'modules/core/CMakeFiles/opencv_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
解决方案
$ sudo apt-get install liblapacke-dev checkinstall
- 在/build文件夹中找到opencv_lapack.h文件,把#include "LAPACKE_H_PATH-NOTFOUND/lapacke.h"改为#include "lapacke.h"
- 重新编译
(2)CUDA 9.0环境下cmake编译时产生的问题
问题如下
在cmake时会产生关于CUDA版本的问题,这种情况在已装CUDA的条件下会出现,未安装时不会有。
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_nppi_LIBRARY (ADVANCED)
linked by target "opencv_cudev" in directory
这是由于CUDA 9.0不支持2.0架构,尝试过网上其他方法,包括在cmake时给命令行加入配置属性如CUDA的路径以及配置,皆无效,而以下方案有效。
解决方案:
1) 在/opencv-3.2.0/cmake文件夹下找到FindCUDA.cmake文件
- 找到
find_cuda_helper_libs(nppi)
改为
find_cuda_helper_libs(nppial)
find_cuda_helper_libs(nppicc)
find_cuda_helper_libs(nppicom)
find_cuda_helper_libs(nppidei)
find_cuda_helper_libs(nppif)
find_cuda_helper_libs(nppig)
find_cuda_helper_libs(nppim)
find_cuda_helper_libs(nppist)
find_cuda_helper_libs(nppisu)
find_cuda_helper_libs(nppitc)
- 找到
set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppi_LIBRARY};${CUDA_npps_LIBRARY}")
改为
set(CUDA_npp_LIBRARY "${CUDA_nppc_LIBRARY};${CUDA_nppial_LIBRARY};${CUDA_nppicc_LIBRARY};${CUDA_nppicom_LIBRARY};${CUDA_nppidei_LIBRARY};${CUDA_nppif_LIBRARY};${CUDA_nppig_LIBRARY};${CUDA_nppim_LIBRARY};${CUDA_nppist_LIBRARY};${CUDA_nppisu_LIBRARY};${CUDA_nppitc_LIBRARY};${CUDA_npps_LIBRARY}")
- 找到
unset(CUDA_nppi_LIBRARY CACHE)
改为
unset(CUDA_nppial_LIBRARY CACHE)
unset(CUDA_nppicc_LIBRARY CACHE)
unset(CUDA_nppicom_LIBRARY CACHE)
unset(CUDA_nppidei_LIBRARY CACHE)
unset(CUDA_nppif_LIBRARY CACHE)
unset(CUDA_nppig_LIBRARY CACHE)
unset(CUDA_nppim_LIBRARY CACHE)
unset(CUDA_nppist_LIBRARY CACHE)
unset(CUDA_nppisu_LIBRARY CACHE)
unset(CUDA_nppitc_LIBRARY CACHE)
2) 找到文件OpenCVDetectCUDA.cmake
删除以下几句
if(CUDA_GENERATION STREQUAL "Fermi")
set(__cuda_arch_bin "2.0")
然后将下一行的elsif改为if
3) 找到文件opencv\modules\cudev\include\opencv2\cudev\common.hpp
添加头文件
#include <cuda_fp16.h>
(3)不支持的GPU architecture问题
问题如下
nvcc fatal : Unsupported gpu architecture 'compute_20'
解决方案
在cmake的时候命令行的参数中加入如下一句
-D CUDA_GENERATION=Kepler
(4)编译到99%或100%时卡住的问题
问题如下
[100%] Built target opencv_perf_stitching
[100%] Built target opencv_python2
这个时候,会一直卡着
解决方案
- 不要终止安装,等一等,或者make -j8甚至make -j12多线程安装可以快一点,一般几分钟可以安装完成
5)在CMakeLists.txt中设置指定的OpenCV版本
解决方案
set(OpenCV_DIR "/your_opencv_path/opencv-3.2.0/build")
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
其中your_opencv_path指你的opencv的安装路径,注意区分大小写。
6)CUDA安装的问题
解决方案
$ sudo add-apt-repository ppa:graphics-drivers/ppa
[环境配置]Ubuntu 16.04 源码编译安装OpenCV-3.2.0+OpenCV_contrib-3.2.0及产生的问题的更多相关文章
- [笔记] Ubuntu 18.04源码编译安装OpenCV 4.0流程
标准常规安装方法安装的OpenCV版本比较低,想尝鲜使用4.0版本,只好源码安装. 安装环境 OS:Ubuntu 18.04 64 bit 显卡:NVidia GTX 1080 CUDA:10.0 c ...
- Ubuntu 16.04 源码编译安装PHP7+swoole
备注: Ubuntu 16.04 Server 版安装过程图文详解 Ubuntu16镜像地址: 链接:https://pan.baidu.com/s/1XTVS6BdwPPmSsF-cYF6B7Q 密 ...
- Ubuntu 16.04 源码编译安装PHP7
一.下载PHP7的最新版源码 php7.0.9 下载地址 http://php.net/get/php-7.0.9.tar.gz/from/a/mirror 二.解压 tar -zxf /tmp/p ...
- Ubuntu 16.04源码编译安装nginx 1.10.0
一.下载相关的依赖库 pcre 下载地址 http://120.52.73.43/jaist.dl.sourceforge.net/project/pcre/pcre/8.38/pcre-8.38.t ...
- 在Ubuntu 16.04 LTS下编译安装OpenCV 4.1.1
目录 一 安装前的准备 二 编译并安装OpenCV 4.1.1 注:原创不易,转载请务必注明原作者和出处,感谢支持! OpenCV目前(2019-8-1)的最新版本为4.1.1.本文将介绍如何在Ubu ...
- ubuntu 16.04源码编译OpenCV教程 | compile opencv on ubuntu 16.04
本文首发于个人博客https://kezunlin.me/post/15f5c3e8/,欢迎阅读! compile opencv on ubuntu 16.04 Series Part 1: comp ...
- ubuntu 16.04源码编译和配置caffe详细教程 | Install and Configure Caffe on ubuntu 16.04
本文首发于个人博客https://kezunlin.me/post/b90033a9/,欢迎阅读! Install and Configure Caffe on ubuntu 16.04 Series ...
- Ubuntu 16.04源码编译boost库 编写CMakeLists.txt | compile boost 1.66.0 from source on ubuntu 16.04
本文首发于个人博客https://kezunlin.me/post/d5d4a460/,欢迎阅读! compile boost 1.66.0 from source on ubuntu 16.04 G ...
- [Part 3] 在Ubuntu 16.04源码编译PCL 1.8.1支持VTK和QT
本文首发于个人博客https://kezunlin.me/post/137aa5fc/,欢迎阅读! Part-3: Install and Configure PCL 1.8.1 with vtk q ...
随机推荐
- JS里设定延时
使用SetInterval和设定延时函数setTimeout 很类似.setTimeout 运用在延迟一段时间,再进行某项操作. setTimeout("function",tim ...
- kettle性能优化
普通开发电脑,如果没有网络查询步骤,kettle正常的速度应该在3000~20000条/秒.如果速度在2000条/秒一下,就可能需要调优. 性能优化的方式包括如下几种: 1.通过改变开始复制的数量(针 ...
- security/pam_appl.h:没有那个文件或目录
在编译开源库时, 提示 pam.h:4:10: 致命错误:security/pam_appl.h:没有那个文件或目录 #include <security/pam_appl.h> 解决方法 ...
- 第 14 章 结构和其他数据形式(enum枚举)
/*----------------------------- enum.c -- 使用枚举类型的值 -----------------------------*/ #include <stdi ...
- 13.4SolrCloud集群使用手册之CRUD
转载请出自出处:http://www.cnblogs.com/hd3013779515/ Student.java package cn.ljh.ssm.test; import org.apache ...
- python第二十八课——编码小常识
2.内存和硬盘: 内存:计算机硬件组成部分之一,它是一个容器,用来存储数据:处理数据速度快, 存储数据量小:断电死机数据会丢失,短暂性存储数据 硬盘:计算机硬件组成部分之一,它是一个容器,用来存储数据 ...
- 1036. [ZJOI2008]树的统计【树链剖分】
Description 一棵树上有n个节点,编号分别为1到n,每个节点都有一个权值w.我们将以下面的形式来要求你对这棵树完成 一些操作: I. CHANGE u t : 把结点u的权值改为t II. ...
- AndroidStudio编译error:app:validateReleaseSigning'Keystore file not found for signing config 'release
使用AndroidStudio编译时提示error: Error:Execution failed for task ‘:app:validateReleaseSigning’. > Keyst ...
- Spark2.3文档翻阅的一点简略笔记(WaterMarking)
写本文原因是之前已经将官网文档阅读过几遍,但是后来工作接触spark机会较少所以没有跟进新特性,利用周末一点闲暇时间粗略阅读一篇,将自己之前遇见过的问题解决过的问题印象不深刻的问题做一下记录. 1关于 ...
- python高速排序
import random def rand(n): for i in range(n): yield random.randint(0,1000) #创建一个随机数列表 def createList ...