Configuring the CMake and OpenCV source files

Now, we can move on to configuring CMake and getting everything set up to build OpenCV as a library to utilize within Unity. Now, to do this, you need the full-on source code of OpenCV, instead of the binaries, which you can grab from https://github.com/opencv/opencv/archive/3.3.0.zip. or https://github.com/opencv/opencv/archive/3.3.0.zip.

Start CMake (CMake-gui). You may again enter it in the start menu search or get it from All Programs | CMake 2.8 | CMake (CMake-gui). First, select the directory for the source files of the OpenCV library (1). Then, specify a directory where you will build the binary files for OpenCV library (2).

Press the Configure button to specify the compiler (and the IDE) you want to use. Note that you can choose between different compilers for making either 64 bit or 32 bit libraries. Select the one you use in your application development.

CMake will start based on your system variables and will try to automatically locate as many packages as possible. You can modify the packages to use for the build in the WITH ‣ WITH_X menu points (where X is the package abbreviation). 

Select all the packages you want to use, and again press the Configure button. For an easier overview of the build options, make sure the Grouped option under the binary directory selection is turned on. For some of the packages, CMake may not find all of the required files or directories. If it doesn't find all of them, CMake will throw an error in its output window (located at the bottom of the GUI) and set its field values to not-found constants.

Press the Configure button again and ensure that no errors are reported. CMake will create the project files by pushing the Generate button. Go to the build directory and open the created OpenCV solution. Depending on just how many options you have selected, the solution may contain quite a lot of projects, so be tolerant on the IDE at the startup. Now, you need to build both the Release and the Debug binaries. Use the drop-down menu on your IDE to change to another of these after building for one of them.

In the end, you can observe the built binary files inside the bin directory.

To collect the header and the binary files, which you will use during your own projects, into a separate directory (similarly to how the pre-built binaries ship), you need to explicitly build the Install project.

To test your build, just go into the Build/bin/Debug or the Build/bin/Release directory and start a couple of applications, such as contours.exe. If they run, you are done.

For more in-depth information on this, go to https://docs.opencv.org/3.0-beta/doc/tutorials/introduction/windows_install/windows_install.html. The OpenCV documentation will go into this in more detail, along with the other tools you will need to install to go down this route.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.183.1