0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

VisualStudio2019 + OpenCV4.5.0 + CUDA10.1 + VideoCodecSDK10.0 の環境構築

Last updated at Posted at 2021-12-31

VisualStudio2019 + OpenCV4.5.0 + CUDA10.1 + VideoCodecSDK10.0 の環境構築

環境構築

参考

ダウンロード・インストール

OpenCV モジュール生成

  • CMakeでOpenCVをビルドするソリューションファイルを生成する
    • cmake-gui 起動
      1. ソースコード
        • E:/Program/OpenCV/opencv/sources
      2. ビルドバイナリ
        • E:/Program/OpenCV/build
      3. Configure
        • Visual Studio 16 2019
        • x64
        • Use default native compilers
        • Finish
      4. Check
        • BUILD_EXAMPLES : ON
        • BUILD_PERF_TESTS : OFF
        • BUILD_TESTS : OFF
        • INSTALL_CREATE_DISTRIB : ON
        • OPENCV_ENABLE_NONFREE : ON
        • OPENCV_EXTRA_MODULES_PATH : E:/Program/OpenCV/opencv_contrib-4.5.0/modules
        • WITH_CUDA : ON
        • WITH_OPENGL : ON
      5. Configure
      6. Check
      7. Configure
      8. Check
        • WITH_NVCUVID : ON
      9. Configure
      10. Generate
  • OpenCVをビルドする
    1. set PATH=C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin;%PATH%
    2. cd /d E:/Program/OpenCV/build
    3. Debug
      1. MSBuild OpenCV.sln /t:build /p:Configuration=Debug;Platform="x64"
      2. MSBuild INSTALL.vcxproj /t:build /p:Configuration=Debug;Platform="x64"
      3. 60min
    4. Release
      1. MSBuild OpenCV.sln /t:build /p:Configuration=Release;Platform="x64"
      2. MSBuild INSTALL.vcxproj /t:build /p:Configuration=Release;Platform="x64"
      3. 60min
  • E:/Program/OpenCV/build/install
    • /include
    • /x64/vc16/bin
    • /x64/vc16/lib
  • 静的ライブラリ生成
    • libのサイズが大きすぎたので停止
      1. Check
        • BUILD_SHARED_LIBS : OFF
        • BUILD_FAT_JAVA_LIB : ON
      2. Configure
      3. Generate
      4. OpenCVをビルド

新規アプリケーション

  • 生成したモジュールの参照
    1. VisualStudio2019で新規ソリューションを作成
      • C++
      • Desktop
      • Console
    2. C/C++
      • 追加のインクルードディレクトリ
        • $(SolutionDir)include 追加
          • E:/Program/OpenCV/build/install/include/opencv2 をコピー
    3. リンカー
      • 追加のライブラリディレクトリ
        • $(SolutionDir)lib/opencv2 追加
          • E:/Program/OpenCV/build/install/x64/vc16/lib 内のファイルをコピー
      • 入力
        • 追加の依存ファイル

          • Debug
            • opencv_core450d.lib
            • opencv_highgui450d.lib
          • Release
            • opencv_core450.lib
            • opencv_highgui450.lib
        • コード上で切り替える場合

          #include "opencv2/opencv.hpp"
          #include "opencv2/highgui.hpp"
          #include "opencv2/core/version.hpp"
          
          #ifdef _DEBUG
          #define LIBEXT CVAUX_STR(CV_VERSION_MAJOR) CVAUX_STR(CV_VERSION_MINOR) CVAUX_STR(CV_VERSION_REVISION) CV_VERSION_STATUS "d.lib"
          #else
          #define LIBEXT CVAUX_STR(CV_VERSION_MAJOR) CVAUX_STR(CV_VERSION_MINOR) CVAUX_STR(CV_VERSION_REVISION) CV_VERSION_STATUS ".lib"
          #endif
          
          #ifdef HAVE_OPENCV_WORLD
          #pragma comment(lib, "opencv_world"    LIBEXT)
          #else
          #pragma comment(lib, "opencv_core"     LIBEXT)
          #pragma comment(lib, "opencv_highgui"  LIBEXT)
          #endif
          
    4. デバッグ
      • 環境
        • PATH=E:/Program/Capture/dll
          • E:/Program/OpenCV/build/install/x64/vc16/bin 内のファイルをコピー
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?