The installation guide presented in Chapter 1, Getting Started, needs a few additional steps in order to include the GPU module. We assume that the computer in which OpenCV is going to be installed already has the software detailed in that guide.
There are new requirements to be satisfied in order to compile OpenCV with CUDA on Windows:
MaintenanceTool
application located in C:Qt
. A good choice is the msvc2012
32-bit component, as can be seen in the following screenshot. It is also necessary to update the Path
environment with the new location (for example, in our local system, it is C:Qt5.2.1msvc2012in
). The Qt library is included in the compilation to take advantage of its user interface features.The build configuration with CMake differs in some points from the typical one explained in the first chapter. These differences are explained as follows:
WITH_CUDA
option. In addition, the installation path of the toolkit is shown through CUDA_TOOLKIT_ROOT_DIR
. Another interesting option is CUDA_ARCH_BIN
because the compilation time can be significantly reduced if we just select the corresponding version of our GPU; otherwise, it will compile the code for all the architectures. As mentioned previously, the version can be checked at http://developer.nvidia.com/cuda-gpus. The following screenshot shows the options set in our build configuration:CMake generates several Visual Studio projects in the target directory, ALL_BUILD
being the essential one. Once it is opened in Visual Studio, we can choose the build configuration (Debug or Release) as well as the architecture (Win32 or Win64). The compilation starts by pressing F7 or by clicking on Build Solution. After the compilation has finished, it is recommended that you open and build the INSTALL
project as it generates an install directory with all the necessary files.
Finally, the Path
system needs to be updated with the location of the newly generated binaries. It is important to remove the previous location from the Path
variable and have only one version of the binaries in it.
Qt Creator should now find two compilers and two Qt versions: one for Visual C++ and one for MingGW. We have to choose the correct kit depending on the developed application when creating a new project. It is also possible to change the configuration of an existing project as kits are manageable.
The installation process can be summarized in the following steps:
Path
system with the new location (for example, C:Qt5.2.1msvc2012in
).WITH_CUDA
, CUDA_ARCH_BIN
, WITH_QT
, and BUILD_EXAMPLES
options.ALL_BUILD
Visual Studio project and build it. Do the same operation with the INSTALL
project.Path
environment variable to update the OpenCV bin directory (for example, C:opencv-buildCudaQtinstallx86vc11in
).