Add Opencv2.4.9__linux to Qt Creator in Linux Ubuntu 14.04 Environment

Source: Internet
Author: User
First of all, thanks to Jia Nan's help.
Environment: Linux Ubuntu 14.04 QT4.8.5 Qt creator2.8.0 OpenCv2.4.9
OPENCV installation has said before, the installation of Qt can be its own Baidu, QT source code compiled when the time is longer, I installed about five hours. Then configure the Qt creator environment.
Now, start adding OpenCV to Qt creator.
1) sudo gedit/usr/share/qt4/mkspecs/default/qmake.conf
The following two sentences were added to the file:
Qmake_incdir =/USR/INCLUDE/OPENCV//install OpenCV directory qmake_libs =-lcvaux-lcv-lcxcore-lhig Hgui-lml
2 A new empty QT project, I named Test. Add OpenCV dynamic link libraries in Test.pro file if you don't know what it is, it's available (pkg-config provide the user with the appropriate library path, version number, and so on to the programPkg-config OpenCV--libs--cflags OpenCV >>opencv.config
(--cflags parameter extracts the options required for compilation,--libs parameter extracts options when connected)
The output of the corresponding information in the Opencv.config, after the modification, my following:
Includepath +=/USR/LOCAL/INCLUDE/OPENCV \/usr/local/include LIBS +=/usr/local/lib/libopencv_c alib3d.so \/usr/local/lib/libopencv_contrib.so \/usr/local/lib/libopencv_core.so \/usr/local/lib/libopencv_ features2d.so \/usr/local/lib/libopencv_flann.so \/usr/local/lib/libopencv_gpu.so \/usr/local/lib/libopencv_ highgui.so \/usr/local/lib/libopencv_imgproc.so \/usr/local/lib/libopencv_legacy.so \/usr/local/lib/libopencv_ ml.so \/usr/local/lib/libopencv_nonfree.so \/usr/local/lib/libopencv_objdetect.so \/usr/local/lib/libopencv_ ocl.so \/usr/local/lib/libopencv_photo.so \/usr/local/lib/libopencv_stitching.so \/usr/local/lib/libopencv_ superres.so \/usr/local/lib/libopencv_ts.a \/usr/local/lib/libopencv_video.so \/usr/local/lib/libopencv_ Videostab.so
Then copy the above to the Test.pro file.
3) test
Use the following code in the main.cpp.
#include <cv.h> #include Note that lena.jpg in the project's directory, refers to the project in the Debug file, such as my "build-testopencv-desktop-debug", otherwise will not show the picture.
And then run, there's a picture of the truth:


At this point, QT add OpenCV complete. The drawback is that after you write the program again, you have to add your own dependent libraries in the. Pro file.

One way to do this is to add the Includepath and Libs content added directly to the
sudo gedit/usr/share/qt4/mkspecs/default/qmake.conf "This will not have to be configured in every project, but it needs to be noticed when porting." "Visible in http://blog.csdn.net/b5w2p0/article/details/8945388

But I found out in the Ubuntu experiment that this method is not successful, OpenCV need "cv.h" and so on or can not find the appropriate path. Therefore, this method is not used.

Welcome to the discussion.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.