Deploying vs + QT + opencv + Darknet (Yolo) integrated environment under win10

Time:2021-10-31

Vs + QT integrated environment

  1. Download vs and QT and install.

    VS:Official website link
    Qt:Download link

  2. Add the bin directory of QT to the path

    Example of bin directory: D: \ development \ QT \ 5.12.0 \ msvc2017_ 64\bin

  3. Download the QT extension of the corresponding version of VS, which can be downloaded in the vs extension store or downloaded from the website and then installed

    Qt Visual Studio Tools:Download connection
    The suffix vsix can be installed directly. If it is Zip or other compressed files, it can be modified to vsix

  4. After installation, open vs and add QT installation path in extension – > QT vs tools – > QT options – > Add.

    If QT is not added to the path in step 3, there may be no clickable options here
    Example of installation path: D: \ development \ QT \ 5.12.0 \ msvc2017_ sixty-four

  5. Create a QT new project. If it is created successfully, it means that the integrated environment has been built.

    There are several QT new projects. If one fails, try the other, because unknown errors may lead to failure

  6. If the above setup is completed, but no package is displayed when the include package is imported, add the include directory of QT to the include directory and the Lib directory of QT to the Library Directory in project – > properties – > VC + + directory

    Example of include directory: D: \ development \ QT \ 5.12.0 \ msvc2017_ 64\include
    Example of Lib Directory: D: \ development \ QT \ 5.12.0 \ msvc2017_ 64\lib

Vs + opencv integrated environment

Note: the environment built in this way cannot be integrated in QT creator. The specific reason is unknown.
  1. Download and unzip the opencv source code, download and install the GUI version of cmake

    OpenCV:Official website link
    CMake:Official website connection

  2. Building opencv using cmakd
    1. Where is the source codeselect the sources directory of OpenCV

      Examples of sources Directory: D: / development / opencv / opencv / sources

    2. Create a build folder in the sources directory and select where to build the binaries

      Example of build directory: D: / development / opencv / opencv / sources / build

    3. Click Configure to generate the configuration list

      If cmakesetup option box pops up:

      1. Specify the generator for this project select the vs version you are using
      2. Optional platform for generator select the platform you use, x64 by default
      3. Then click finish
    4. In the generated configuration list, find “build_opencv_world” and check it, then click Configure, click generate after completion, and click open project after completion.

      The advantage of this is that the opencv module can be built into a library (DLL file), which is easy to add in vs

  3. Generating opencv using vs
    1. Click build – > batch build
    2. Tick “all_build” and “Install” (there are 4)
    3. Click build
  4. Add the opencv DLL file to the path environment variable. The DLL file is the bin directory under the Lib peer directory above

    Path example: D: \ development \ opencv \ opencv \ sources \ build \ install \ x64 \ vc16 \ bin

  5. Configure vs + opencv environment
    1. Select the VC + + directory in project – > properties, add the include directory in the include directory, and add the Lib directory in the library directory

      Example of include directory: D: \ development \ opencv \ opencv \ build \ include
      Example of Lib Directory: D: \ development \ opencv \ opencv \ build \ x64 \ VC15 \ Lib

    2. Select the input tab of the linker and add the two. Lib files in the Lib directory to the additional dependency

      give an example:
      D:\development\OpenCV\opencv\build\x64\vc15\lib\opencv_world346.lib
      D:\development\OpenCV\opencv\build\x64\vc15\lib\opencv_world346d.lib

  6. Create a new QT file or command line application, and then use the opencv function. If no error is reported, the environment construction is completed.

Darknet deploy Yolo

  1. Download the zip package or clone source code of Darknet from GitHub, or download it from gitee’s domestic warehouse, which is faster

    Darknet:GitHub warehouse addressOne of gitee warehouse addresses

  2. Download CUDA and cudnn. CUDA > = 10.2 is required. The available version of cudnn is the same as CUDA. Cndnn should log in

    CUDA:Official address
    cnDNN:Official address

  3. After CUDA installation, open C: \ program files \ NVIDIA GPU computing toolkit \ CUDA \ v11.0 to extract and overwrite cndnn files
  4. Change the CUDA version in the darknet.vcxproj file in the build directory of the Darknet source code to the installed version.

    Example of darknet.vcxproj file path: D: \ development \ tools \ Darknet \ build \ Darknet

  5. Use cmake GUI to build the Darknet source code, set where is the source code and where to build the binaries (note that there is already a build folder in the source code, do not select it), and click Configure – > finish (the options are the same as above) – > generate  -> Open project, after opening vs, change debug to release, select x64 platform, and then click generate – > generate solution in the menu. As long as the generation is successful, the environment has been built successfully.
  6. Add darknet.exe to the path. Darknet.exe is in the release file of the generated folder. So far, the environment construction has been completed

    Path example: D: \ development \ tools \ Darknet \ newbuild \ release

  7. If you prompt CUDA error: no kernel image is available for execution on the device when using Yolo, it indicates that the CUDA version is too high and does not support the current graphics card. Please reduce the version.
  8. If you are prompted that pthreadscv2.dll cannot be found when using Yolo, go to the 3rd party folder of Darknet and copy pthreads.dll to C: \ windows \ syswow64 and C: \ windows \ system32

    Pthreadscv2.dll path example: D: \ development \ tools \ Darknet \ 3rdparty \ pthreads \ bin