Recently, OpenCV has published 3.0 alpha version, however, heard from some colleague, the compilation has some problems. Thus, I decided to update my current 2.4.0 version to 2.4.9, and install QT alongside.
Here is a very good instruction for installing OpenCV 2.4.9. One thing to be aware is the options of setting cmake. In the post, QT is set ON by command -D WITH_QT=ON. Whereas, the version of this QT is 4.x, but newest QT library is 5.2. With the QT option on, when compiling OpenCV program in QT Creator, the program will crash with errors like realloc(): invalid pointer. Hence, make sure to set WITH_QT=OFF.
Since there are many options available for installing OpenCV, it is more convenient to use cmake-gui to select the options. Another option that could be set on is the openni (-D WITH_OPENNI=ON ), which can be used for development of Kinect. Before setting it on, OpenNI library should be installed as below.
$ sudo apt install libopenni-dev $ sudo apt install libopenni-sensor-primesense-dev
To install QT Creator, the program can be downloaded at the official website or by command. The following codes shows the installation of QT Creator 3.1.2 for 64bit Ubuntu 14.04.
$ wget http://download.qt-project.org/official_releases/qt/5.3/5.3.2/qt-opensource-linux-x64-5.3.2.run $ chmod +x qt-opensource-linux-x64-5.3.2.run $ ./qt-opensource-linux-x64-5.3.2.run
When compiling OpenCV in QT Creator, don’t forget to add the include and library path of OpenCV in .pro file.
INCLUDEPATH += `pkg-config --cflags opencv` LIBS += `pkg-config —libs opencv`
QT creator provides an effective way to create GUI, but it should be avoided using OpenCV windows alongside QT window. For example, in QT GUI function call imshow(), which often generates a warning: Gtk-WARNING **: gtk_disable_setlocale() must be called before gtk_init(). It is better to convert cv::Mat to QImage and draw it on a Qt window.
To install a new version of OpenCV, the old version should be uninstalled first. Go to the build folder where OpenCV is installed, run command:
$ sudo make uninstall
The following two pictures show the GUI used for the ground station to monitor and navigate the robot ROSA and the control GUI for setting the parameters of ROSA using QT from my master thesis.