Windows does not provide Visual Studio ``*.sln`` file directly and requires CMake to build. Firstly, CMake can be used across multiple platforms, it is easy to configure and can be maintained in a sustainable way. Secondly, the third-party codes (Glog, OpenCV) are built using CMake.
..tip::
There is currently no binary installer available, which requires you to compile from source. It is also the process of configuring the development environment.
Prerequisites
-------------
CMake (provide build)
~~~~~~~~~~~~~~~~~~~~~~
*`CMake <https://cmake.org/download/>`_,used to build and compile (necessary).
*`Git <https://git-scm.com/downloads>`_, used to get code (optional).
*`Doxygen <http://www.stack.nl/~dimitri/doxygen/download.html>`_, used to generate documents (optional).
After you install the above tools, confirm that you can run this command in CMD (Command Prompt):
..code-block:: bat
>cmake --version
cmake version 3.10.1
>git --version
git version 2.11.1.windows.1
>doxygen --version
1.8.13
Visual Studio (provide compilation)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*`Visual Studio <https://www.visualstudio.com/>`_
*`Visual Studio 2017 <https://my.visualstudio.com/Downloads?q=Visual Studio 2017>`_
*`Visual Studio 2015 <https://my.visualstudio.com/Downloads?q=Visual Studio 2015>`_
In Visual Studio command Prompt, you can use the compile command ``cl````link````lib````msbuild``, etc.(need finish ``MSYS2``and ``Getting Source Code`` steps first)
The official OpenCV provides the ``exe`` for installation. If you want to compile from the source code, see the Official document `Installation in Windows <https://docs.opencv.org/master/d3/d52/tutorial_windows_install.html>`_ . or refer to the following command:
If OpenCV is installed in a custom directory or wants to specify a version, you can set the path as follows before compiling:
..code-block:: bat
# OpenCV_DIR is hte path where OpenCVConfig.cmake in
set OpenCV_DIR=C:\opencv
Otherwise, CMake will prompt that OpenCV could not be found. If you don't want to rely on OpenCV, read :ref:`sdk_without_opencv` .
Build and install:
..code-block:: bat
cd <sdk>
make install
Finally, the SDK will install in ``<sdk>/_install`` by default.
Building samples
----------------
..code-block:: bat
cd <sdk>
make samples
Run samples:
..code-block:: bat
.\samples\_output\bin\api\camera_a.bat
For tutorial samples, please read :ref:`data` and :ref:`ctrl` .
..tip::
All compiled sample programs ``exe`` will have a corresponding ``bat``. ``bat`` will temporarily set system environment variables and then run ``exe``. So it is recommended to run ``bat``.
If you run``exe`` directly, it may prompt that cannot find ``dll``. Then you should add ``<sdk>\\_install\\bin````%OPENCV_DIR%\\bin`` to ``PATH`` in system environment variable.
How to set the environment variable for OpenCV, refer to the official document `Set the OpenCV environment variable and add it to the systems path <https://docs.opencv.org/master/d3/d52/tutorial_windows_install.html#tutorial_windows_install_path>`_ .
Building tools
---------------
..code-block:: bat
cd <sdk>
make tools
The usage of tools and scripts will be introduced later.
..tip::
The script is based on Python. You need to install Python and its package management tool pip first, and then install the dependencies as follows:
..code-block:: bat
cd <sdk>\tools
pip install -r requirements.txt
Note: Python is also in MSYS2, but fail install Matplotlib in test.
Conclusion
-----------
If your project will use SDK, you can refer to the settings in ``samples/CMakeLists.txt`` for CMake. Or just import the head file and dynamic library in the installation directory.