Recently, I did a fresh installation of Windows 10 on my laptop and had to reinstall OpenCV. Since I use OpenCV version 3.0.0 in my office and have the source available, I decided to build it instead of downloading pre-compiled binaries. In this article, I will describe how I build OpenCV 3.0.0 using CMake and Visual Studio and set up my development environment.
Softwares
- OpenCV 3.0.0
- Visual Studio 2015 Community Edition
- CMake 3.9.3
Description
I put the OpenCV source (extracted) in C:\opencv\sources
directory. The reason is simply to make it identical to my office PC. Other uses of directories/names in this article is also for the same purpose. I already had Visual Studio 2015 installed. I downloaded and installed CMake and opened the graphical UI application CMake (cmake-gui)
from the Start menu.
In CMake, I selected the source folder C:\opencv\sources
through Browse Source
button. I also selected C:\opencv\sources\build
as the directory for building binaries. Then I pressed Configure
button. In the pop-up window, I selected Visual Studio 14 2015
as the generator and selected the option Use default native compilers
. After configuration was completed, there were several warnings, but I ignored them.
I only changed the option CMAKE_INSTALL_PREFIX
to C:\opencv\build
. I used default values for all other options. I pressed the Generate
button and waited for CMake to generate the project files for building OpenCV. Then I opened the generated projects in VS2015 using the Open Project
button.
In VS2015, I build all projects using Build Solution
. for both Debug and Release configurations. 54 projects were built succefully, 23 skipped and a 2 failed due to errors. I ignored the failed projects as I don't need those functionalities.
Then I built the INSTALL
project (under CMake Targets
in Solution Explorer) which was skipped in the last step. This will create three folders in the location C:\opencv\build
as directed during CMake configuration step. They are:
include
: contains header filesetc
: data files for cascade classifiersx86
: binary and library files in separate subdirectories
The final step is to include the location C:\opencv\build2\x86\vc14\bin
in system path so that programs using OpenCV library can find the necessary DLLs.
Comments
Post a Comment