环境:
系统环境Ubuntu14.04+opencv2.4.13+Qt4.x/Qt5.x+Opengl
IDE qt-opensource-linux-x64-5.9.1
--------------------------------------------------------------------------------------------
在QtCreator中新建工程编译运行opencv-2.4.13/samples/cpp/Qt_sample(源码下载)
错误一:
提示opengcv编译没有打开WITH_OPENGL=ON
编译opencv的时候用下面的方法:
1 下载opencv2.4.13的源码
2 解压后进入源码目录并新建目录release
3 打开terminal
>>cd release
>>cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D CMAKE_INSTALL_PREFIX=/usr/local ..
这里请确认输出里面有QT OpengGL support: YES
-- GUI:
-- QT 4.x: YES (ver 4.8.6 EDITION = OpenSource)
-- QT OpenGL support: YES (/usr/lib/x86_64-linux-gnu/libQtOpenGL.so)
-- OpenGL support: YES (/usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so)
-- VTK support: NO
--------------------------------------------------------------------------
如果需要GUI里面是在QT5.x里面运行的。
使用如下命令编译:
cmake -D CMAKE_BUILD_TYPE=RELEASE -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D CMAKE_INSTALL_PREFIX=/usr/local ..-D CMAKE_PREFIX_PATH=/home/android/Qt5.9.0/5.9/gcc_64/lib/cmake
这里的CMAKE_PREFIX_PATH用来指定QT5的路径。
当然,如果系统默认就是Qt5的环境的话,应该可以不用加这句。
CMake的配置输出的GUI应该是如下:
-- GUI:
-- QT 5.x: YES (ver ..)
-- QT OpenGL support: YES (Qt5::OpenGL ..)
-- OpenGL support: YES (/usr/lib/x86_64-linux-gnu/libGLU.so /usr/lib/x86_64-linux-gnu/libGL.so)
-- VTK support: YES (ver 5.8.0)
--------------------------------------------------------------------------
>>cd release
>>make
>>sudo make install
错误二:
*** Error in `/home/android/Opensource/Qt_WorkSpace/build-OpencvTest-Desktop_Qt_5_9_0_GCC_64bit-Debug/OpencvTest': realloc(): invalid pointer: 0x00007fcf34476840 ***
Press <RETURN> to close this window...
原因:
由于我用的是qt-opensource-linux-x64-5.9.1,里面QtCreator默认配置的是Qt5.9.1的环境,跟编译opencv时的用的qt4.8.6不一致导致
解决方法:
QtCreator->Options->Build&Run->Kits里面添加一项:
然后重新建工程
在选择Kits的时候,勾选刚刚添加的Qt Desktop 4.8.6GCC 64bit
然后编译运行就会OK
PS:网上一堆人说要去除编译opencv的配置WITH_QT=ON,这个根本就不行,我们就是要在QT里面跑OPENCV+opengl,怎么能去除支持QT?
-------------------
搭建qt opencv环境
http://www.jb51.cc/article/p-wzppwpey-ev.html
opencv2 opencv3 共存
http://www.linuxidc.com/Linux/2017-01/139325.htm
切换命令:
sudo sh -c 'echo "/home/android/Opensource/opencv-3.3.0/build/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
---------------------------------------------------------------------------------------------------------------------------
opencv3 + ubuntu + opencv contrib + python环境最棒的教程:
http://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/
遇到问题一:
The following packages have unmet dependencies:
libjasper-dev : Depends: libjasper1 (= 1.900.1-14ubuntu3) but 1.900.1-14ubuntu3.2 is to be installed
libtiff4-dev : Depends: libtiff5-dev (> 4.0.3-6~) but it is not going to be installed
E: Unable to correct problems,you have held broken packages.
遇到问题二:
The following information may help to resolve the situation:
The following packages have unmet dependencies:
libjasper-dev : Depends: libjasper1 (= 1.900.1-14ubuntu3) but 1.900.1-14ubuntu3.2 is to be installed
libtiff4-dev : Depends: libtiff5-dev (> 4.0.3-6~) but it is not going to be installed
E: Unable to correct problems,you have held broken packages.
解决办法:更新源
按照http://blog.csdn.net/u010053463/article/details/49300625
个人全部替换为163的源,问题解决
原文链接:https://www.f2er.com/ubuntu/351762.html