Ubuntu 10.04.3 LTS ("fresh" install) OpenCV 2.3.1 Qt SDK version 1.2.0 for Linux/X11 32-bit
 
参考这份文档:
 
下载OpenCV-2.3.1a.tar.bz2
打开终端
$ sudo apt-get update
$ sudo apt-get install build-essential cmake libgtk2.0-dev libtiff4-dev libjasper-dev libavformat-dev libswscale-dev libavcodec-dev libjpeg62-dev
进入OpenCV-2.3.1a.tar.bz2所在目录
$ bzip2 -d OpenCV-.2.3.1a.tar.bz2
$ tar -xvf OpenCV-2.3.1a.tar
$ cd OpenCV-2.3.1/
$ mkdir release
$ cd release
$ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
$ make
$ sudo make install
$ sudo ldconfig -v
$ export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
在.pro文件中加入
 LIBS += `pkg-config opencv --cflags --libs`
或者
LIBS += -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_legacy -lopencv_flann
 可以了
 
方法二:
$ sudo apt-cache search opencv
$ sudo apt-get install libcv-dev libcv4 libcvaux-dev libcvaux4 libhighgui-dev libhighgui4  opencv-doc
$ sudo gedit /home/zhang/QtSDK/Desktop/Qt/4.8.0/gcc/mkspecs/default/qmake.conf
添加
QMAKE_INCDIR = /usr/include/opencv
QMAKE_LIBS = -lcvaux -lcv -lcxcore -lhighgui -lml
下面的也可加在pro文件里,在qmake.conf中更方便
INCLUDEPATH += /usr/include/opencv
LIBS += /usr/lib/libcv.so \
/usr/lib/libcvaux.so \
/usr/lib/libcxcore.so \
/usr/lib/libhighgui.so \
/usr/lib/libml.so
 
 
OpenGL
sudo apt-get install mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev
如果项目里不需要glut的话,后面两个都可以不要。
测试 加上-lglut
g++ sample.cpp -o sample -lglut
./sample
 
 
QTCreator中使用
OpenCV:
在.pro文件中加入
 LIBS += `pkg-config opencv --cflags --libs`

 具体参考上面的内容

 

OpenGL

在.pro文件中加入

QT +=opengl

要用glut.h

LIBS += -lglut 

 
ubuntu查看OpenGL版本信息
sudo apt-get install mesa-utils
glxinfo | grep 'OpenGL version string'
Logo

更多推荐