installing opencv 2.4.x with qt
TRANSCRIPT
Installing OpenCV
2.4.x with Qt
Luigi De Russis
Politecnico di Torino Dipartimento di Automatica e Informatica (DAUIN)
Torino - Italy
This work is licensed under the Creative Commons (CC BY-SA)
License. To view a copy of this license, visit
http://creativecommons.org/licenses/by-sa/3.0/
11/9/2012 Luigi De Russis - Computer Vision - OpenCV
Installation
2
0. Getting started…
Official installation guides
Currently, only for Linux and Windows
http://docs.opencv.org/doc/tutorials/introduction/table_of_c
ontent_introduction/table_of_content_introduction.html
Prerequisites:
[Mac OS X] Xcode with command line tools installed
[Linux] GCC 4.4 or later
N.B. This tutorial has been tested with OpenCV
2.3.1, 2.4.2, and 2.4.3 under Windows 7 and Mac
OS X 10.7+
Luigi De Russis - Computer Vision - OpenCV 3
1. Qt SDK (I)
Download and install Qt SDK from http://qt-
project.org/downloads, using the offline installer
(current SDK release 1.2.1)
[Windows-only] Perform a custom installation,
installing all the MinGW stuff. Components about
Harmattan, Symbian, etc. are not necessary for our
purpose (see next slide)
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 4
1. Qt SDK (II) - Windows
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 5
1. Qt SDK (II) - Windows
At the end, check if the folder
C:\QtSDK\mingw\bin (or similar)
is included in the PATH variable
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 6
2. OpenCV 2.4.x
Download and unpack OpenCV 2.4.x from
http://opencv.org/
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 7
3. Cmake (I)
Download and install Cmake from
http://www.cmake.org/
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 8
3. Cmake (II)
Create two new folders named “cmake-debug” and
“cmake-release” inside the opencv folder
Create a folder named “build_with_Qt” (or similar)
wherever you want
create two new folders named “debug” and “release” inside
the “build_with_Qt” folder
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 9
3. Cmake (II)
Create two new folders named “cmake-debug” and
“cmake-release” inside the opencv folder
Create a folder named “build_with_Qt” (or similar)
wherever you want
create two new folders named “debug” and “release” inside
the “build_with_Qt” folder
It is not strongly mandatory… it
is only a “best practice”!
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 10
3. Cmake (IV)
Run Cmake
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 11
3. Cmake (V)
“Where is the source code” field requires the
location of the opencv folder
“Where to build the binaries” field requires the
location of the “cmake-debug” folder, previously
created
Now press the button “Configure”…
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 12
3. Cmake (VI)
In the next window, select “MingGW Makefiles”
under Windows, “Unix Makefiles” otherwise
Then, press “Finish”
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 13
3. Cmake (VII)
The Cmake window should appear in this way:
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 14
3. Cmake (VIII)
Open the CMAKE entry
assign the value Debug to the CMAKE_BUILD_TYPE
variable
change the CMAKE_INSTALL_PREFIX to match the
“build_with_Qt/debug” folder
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 15
3. Cmake (IX)
Open the WITH entry: check WITH_QT
uncheck useless values (CUDA, CUFFT, EIGEN, and PVAPI, typically)
Press “Configure”, again
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 16
3. Cmake (X)
Open the Ungrupped Entries (or QT) with a red
background and add the location of qmake to the
variable QT_QMAKE_EXECUTABLE
[Windows] qmake is in /Desktop/Qt/4.8.1/mingw/bin inside
the folder where Qt SDK has been installed
[Linux/Mac] qmake is in /Desktop/Qt/4.8.1/gcc/bin inside
the folder where Qt SDK has been installed
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 17
3. Cmake (XI)
Click again on “Configure” (until the entries
background becomes totally white)
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 18
3. Cmake (XII)
Press “Generate”
Repeat the steps reported on slides 11 - 18,
changing:
the build destination folder from “cmake-debug” to “cmake-
release”
the value of the CMAKE_BUILD_TYPE variable (in the
CMAKE entry) to Release
the value of the CMAKE_INSTALL_PREFIX variable (in the
CMAKE entry) to match the “build_with_Qt/release” folder
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 19
4a. Final steps, on Linux/Mac
(I)
Open the terminal, move to the “cmake-debug”
folder, type “make -jN”, where N is the number of
threads to use, and press enter
Wait…
Type “make install” to complete the OpenCV
installation
Repeat the previous three steps for the “cmake-
release” folder
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 20
4a. Final steps, on Linux/Mac
(II)
Add the following folders:
/build_with_Qt/debug/bin
/build_with_Qt/release/bin
to the DYLD_LIBRARY_PATH (Mac) or
LD_LIBRARY_PATH (Linux) environment variable.
You can perform this operation right inside QtCreator (“Build
Environments” field inside the Projects” tab).
Copy the file “opencv.hpp” from “/include/opencv2”
to “include” (in your “builds_with_Qt” folder)
Done: you can start to use OpenCV with Qt!
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 21
4b. Final steps, on Windows (I)
Open the command prompt, move to the “cmake-debug”
folder, type “mingw32-make –j N”, where N is the
number of threads to use, and press enter
Wait…
Type “mingw32-make install” and press enter
Repeat the previous three steps for the “cmake-release”
folder
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 22
4b. Final steps, on Windows
(II)
Add to the PATH environment variable the following
folders:
/build_with_Qt/debug/bin
/build_with_Qt/release/bin
QtSDK/Desktop/Qt/4.8.1/mingw/bin
How do I set the PATH
variable? Read here. You can also perform this
operation inside QtCreator (“Build
Environments” field inside the
Projects” tab).
11/9/2012
Luigi De Russis - Computer Vision - OpenCV 23
4b. Final steps, on Windows
(III)
Copy the file “opencv.hpp” from “/include/opencv2”
to “include” (in your “build_with_Qt” folder)
Done: you can start to use OpenCV with Qt!
11/9/2012