在Ubuntu14.04.5上安装OpenCV2.4.9时遇到的各种问题
来源:互联网 发布:台达plc温度模块编程 编辑:程序博客网 时间:2024/06/05 17:05
从昨天到今天
首先,我是按照这个博客进行安装的,虽然他是以Opencv3.0为样板但是安装基本都大同小异.
(博客地址:http://blog.csdn.net/dreamsky168/article/details/49928293)
1、安装opencv所需的库(编译器、必须库、可选库)
转载请说明 http://www.cnblogs.com/llxrl/p/4471831.html
- GCC 4.4.x or later
- CMake 2.6 or higher
- Git
- GTK+2.x or higher, including headers (libgtk2.0-dev)
- 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
1 [compiler] sudo apt-get install build-essential2 [required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev3 [optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev然后在进行到第二步的时候就出现了error(这是一个我最怕的单词....),报的错如下所示
Reading package lists... DoneBuilding dependency tree Reading state information... DoneSome packages could not be installed. This may mean that you haverequested an impossible situation or if you are using the unstabledistribution that some required packages have not yet been createdor been moved out of Incoming.The following information may help to resolve the situation:The following packages have unmet dependencies: libgtk2.0-dev : Depends: libglib2.0-dev (>= 2.27.3) but it is not going to be installed Depends: libgdk-pixbuf2.0-dev (>= 2.21.0) but it is not going to be installed Depends: libpango1.0-dev (>= 1.20) but it is not going to be installed Depends: libatk1.0-dev (>= 1.29.2) but it is not going to be installed Depends: libcairo2-dev (>= 1.6.4-6.1) but it is not going to be installedE: Unable to correct problems, you have held broken packages.
然后参见网页(https://askubuntu.com/questions/884413/unable-to-install-libgtk2-0-dev-on-ubuntu-16-04)解决了这个问题.其实就是sudo apt-get install libglib2.0-dev libglib2.0-0=2.48.0-1ubuntu4
这句命令.然后再执行sudo apt-get install libgtk2.0-dev
就可以了.第三步倒是没有什么问题.
2、从官网下载最新opencv源码(2.4以上)
http://sourceforge.net/projects/opencvlibrary/
或者github
3、编译opencv
将opencv放至任意目录,解压
unzip opencv- 3.0. 0-rc1. zip (根据我的实际情况,这里是OpenCV-2.4.9)
创建编译目录,编译
1 cd ~/opencv-2.4.9 2 mkdir release 3 cd release 4 cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. 5 make 6 sudo make install然后这里的第5步又出错了....但根据博客'unspported gpu architecture compute_11 解决办法'(http://blog.csdn.net/sysuwuhongpeng/article/details/45485719)应该是在第4步上做修改
将第4步改为 cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D CUDA_GENERATION=Kepler ..
这个问题就可以解决了~之后再次运行make
还是有问题,只不过是其他地方出了问题./home/ubuntu/opencv-2.4.9/modules/gpu/src/nvidia/core/NCVPixelOperations.hpp(51): error: a storage class is not allowed in an explicit specialization
参考网页(https://devtalk.nvidia.com/default/topic/793805/opencv-2-4-9-won-t-compile/?offset=2)把NCVPixelOperations.hpp里的 template function中关键字"static"全部去掉这个问题就解决了(注意,文件中其他地方的"static"还是保留的).
同样,再次运行make这个过程就很慢,然后很不幸地又发现了错误,不过这也在意料之中哦.经过上面几次折腾出现错误也不慌了.报错如下:modules/cudalegacy/src/graphcuts.cpp:120:54: error: ‘NppiGraphcutState’ has not been declaredtypedef NppStatus (*init_func_t)(NppiSize oSize, NppiGraphcutState** ppState, Npp8u* pDeviceMem);
这是因为opecv3.0与cuda8.0不兼容导致的。解决办法:
修改 ~/opencv/modules/cudalegacy/src/graphcuts.cpp文件内容,如图:
有类似错误的文件只要修改这一个文件就好.后面make就畅通无阻了,哈哈哈哈哈哈.4、测试opencv
1) 创建工作目录
mkdir ~/opencv-lenacd ~/opencv-lenagedit DisplayImage.cpp
2) 编辑如下代码
#include <stdio.h>#include <opencv2/opencv.hpp>using namespace cv;int main(int argc, char** argv ){ if ( argc != 2 ) { printf("usage: DisplayImage.out <Image_Path>\n"); return -1; } Mat image; image = imread( argv[1], 1 ); if ( !image.data ) { printf("No image data \n"); return -1; } namedWindow("Display Image", WINDOW_AUTOSIZE ); imshow("Display Image", image); waitKey(0); return 0;}
3) 创建CMake编译文件
gedit CMakeLists.txt
写入如下内容
cmake_minimum_required(VERSION 2.8)project( DisplayImage )find_package( OpenCV REQUIRED )add_executable( DisplayImage DisplayImage.cpp )target_link_libraries( DisplayImage ${OpenCV_LIBS} )
4) 编译
cd ~/opencv-lenacmake .make
5) 执行
此时opencv-lena文件夹中已经产生了可执行文件DisplayImage,下载lena.jpg放在opencv-lena下,运行
附上这次所有帮助我解决一切问题的网址:
http://blog.csdn.net/sysuwuhongpeng/article/details/45485719
https://ubuntuforums.org/showthread.php?t=2244063
https://devtalk.nvidia.com/default/topic/793805/opencv-2-4-9-won-t-compile/?offset=2
https://askubuntu.com/questions/884413/unable-to-install-libgtk2-0-dev-on-ubuntu-16-04
阅读全文
0 0
- 在Ubuntu14.04.5上安装OpenCV2.4.9时遇到的各种问题
- ubuntu14.04安装opencv2.4.9以及遇到的问题
- ubuntu14.04 虚拟机安装opencv2.4.10,make遇到的问题
- opencv2.4.13在ubuntu14.04上的安装
- ubuntu14 上安装tensorflow 遇到的问题
- 关于freeswitch1.5在ubuntu14.04上安装遇到的问题1
- 在ubuntu14.04上安装cuda时会遇到的几个问题
- Ubuntu14.04LTS下Qt5.3.2和OpenCV2.4.9环境的搭建以及遇到的问题
- 安装opencv2.4.8遇到的问题
- 关于calltree在ubuntu14.04上的安装问题
- 在Centos上安装webmin时遇到的一些问题
- ubuntu14.04 安装openCV2.4.9
- ubuntu14.04安装opencv2.4.9
- Ubuntu14.1 安装 搜狗输入法时遇到的问题
- ubuntu14.04安装matlab2010遇到的问题
- 个人在Ubuntu16安装完成后遇到的各种问题。
- 在ubuntu14.04上使用git clone遇到问题
- 在VS2010下安装配置OpenCV2.3 ; 全程截图 + 遇到的问题
- iOS UITextView增加链接 交互
- 利用python实现简单的爬虫,爬百度文库相关词条信息
- win下使用realsense进行数据修正并获取三维坐标
- Cross-Scale Cost Aggregation for Stereo Matching
- cv2读取图像
- 在Ubuntu14.04.5上安装OpenCV2.4.9时遇到的各种问题
- Python Selenium递归遍历frame定位元素
- 剑指offer_扑克牌顺子
- 软件工程之软件配置管理
- 大话设计模式阅读笔记-建造者模式
- JAVA动态代理
- 第十二周OJ-Q24解题方法
- 关于用display:table让元素居中的小结
- python中tkinter模块创建用户登录窗口