61ic电子在线 首页 技术 图像技术 查看内容

Ubuntu14.04 QtCreator中配置OpenCV

2017-5-29 14:44| 发布者: admin| 查看: 1801| 评论: 0|原作者: Liyi|来自: 61ic

摘要: 包含详细步骤。

1. 先从sourceforge上下载OpenCV的最新源码(以OpenCV-2.4.3为例)
https://github.com/itseez/opencv
2. 解压到任意目录
tar xvfj OpenCV-2.4.3.tar.bz2  
3. 进入源码目录,创建release目录
cd OpenCV-2.4.3  
mkdir release  
4. 可以看到在OpenCV目录下,有个CMakeLists.txt文件,需要事先安装一些软件
sudo apt-get install build-essential cmake libgtk2.0-dev pkg-config Python-dev python-numpy libavcodec-dev libavformat-dev libswscale-dev  
5.  进入release目录,安装OpenCV是所有的文件都会被放到这个release目录下
cd release  
6. cmake编译OpenCV源码,安装所有的lib文件都会被安装到/usr/local目录下
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..  
7. 安装
sudo make install  
8.至此,OpenCV安装完毕
头文件位于/usr/local/include
库文件位于/usr/local/lib
9.假设您已经安装好QtCreator,在qmake.conf中设置OpenCV路径
sudo gedit ~/qt4.8.6/mkspecs/default/qmake.conf(视个人安装路径而定)
向qmake.conf中添加如下内容
QMAKE_INCDIR = /usr/local/include/opencv
QMAKE_LIBS = -lopencv_imgproc  -lopencv_core -lopencv_highgui -lopencv_ml
以下部分放入qmake.conf或,pro中均可(本人是放在pro中,网上很多写的放在qmake.conf中,但是本人没成功)
INCLUDEPATH += /usr/local/include/opencv \
               /usr/local/include/opencv2
LIBS += /usr/local/lib/libopencv_video.so  \
  /usr/local/lib/libopencv_ts.so \
  /usr/local/lib/libopencv_objdetect.so \
  /usr/local/lib/libopencv_ml.so  \
  /usr/local/lib/libopencv_legacy.so \
  /usr/local/lib/libopencv_core.so \
  /usr/local/lib/libopencv_features2d.so  \
  /usr/local/lib/libopencv_imgproc.so \
  /usr/local/lib/libopencv_highgui.so \
  /usr/local/lib/libopencv_gpu.so \
  /usr/local/lib/libopencv_flann.so   \
  /usr/local/lib/libopencv_contrib.so \
  /usr/local/lib/libopencv_calib3d.so
10.直接编译可能出现error while loading shared libraries: libXXX.so.X: cannot open shared object file: No such file报错,执行以下命令即可
cd /etc
sudo gedit ld.so.conf   (添加 /usr/local/lib)
sudo ldconfig 更新
11.再次编译,成功
附编译Qt source过程
tar -xvzf qt-everywhere-opensource-src-4.8.6.tar.gz
cd qt-everywhere-opensource-src-4.8.6
./configure -prefix /opt/qt-4.8.6-x11     (-prefix后面是安装目录)
make
sudo make install

鲜花

握手

雷人

路过

鸡蛋

地址 :湖南省株洲市天元区利江花园
合作 Email: administration@61ic.com

  • 关注61ic官方微博
    了解最新动态

  • 关注61ic微信公众号
    这里有好玩的讯息

  • 加入61ic交流群
    不断在这里成长

© 2014-2017 HuNan 湖南索炜达电子科技有限公司 . All rights reserved.
湘公网安备 43020202000020号

Archiver|手机版|小黑屋||湘ICP备13001086号-2 QQ 
返回顶部