OpenCV C++ 手動編譯版本 Visual Studio 專案設定

每次開新的專案都要設定一次,還要手動去翻資料夾複製路徑太麻煩,所以就來整理個一篇。我用的 OpenCV 是用 CMake 自行編譯含有 CUDA 的版本,操作流程我是參考 Build OpenCV GPU Version On Windows 10 – 程式設計之旅,全部照做通常是沒問題,但有些電腦會卡在 cuDNN 無法被偵測到的狀況,這我之後再寫一篇解法。

如果你是直接拿官方編譯好的不能看這篇,請轉:

如何在 Visual Studio 2022 安裝 OpenCV C++ 開發環境?

資料夾設定

這邊先列出我的資料夾路徑放置結構,還沒編譯的先去看 程式設計之旅 的文章,就會知道結構長怎樣了。

OpenCV 原始碼資料夾

D:\Libraries\opencv\opencv

OpenCV Contrib 原始碼資料夾

D:\Libraries\opencv\opencv_contrib

OpenCV Build CMake Build 資料夾

D:\Libraries\opencv\opencv\build

OpenCV Build CMake Build 結果資料夾 (實際用於專案參考)

D:\Libraries\opencv\opencv\build\install

專案屬性設定

開啟專案後,從上方導覽列進入 專案 > 屬性,組態需設定為「Release」。

其他 Include 庫

位置:C/C++ > 一般

D:\Libraries\opencv\opencv\build\install\include

其他程式庫目錄

位置:連結器 > 一般

D:\Libraries\opencv\opencv\build\install\x64\vc17\lib

其他相依性

位置:連結器 > 輸入

$(CoreLibraryDependencies)
%(AdditionalDependencies)
opencv_aruco460.lib
opencv_barcode460.lib
opencv_bgsegm460.lib
opencv_bioinspired460.lib
opencv_calib3d460.lib
opencv_ccalib460.lib
opencv_core460.lib
opencv_cudaarithm460.lib
opencv_cudabgsegm460.lib
opencv_cudacodec460.lib
opencv_cudafeatures2d460.lib
opencv_cudafilters460.lib
opencv_cudaimgproc460.lib
opencv_cudalegacy460.lib
opencv_cudaobjdetect460.lib
opencv_cudaoptflow460.lib
opencv_cudastereo460.lib
opencv_cudawarping460.lib
opencv_cudev460.lib
opencv_datasets460.lib
opencv_dnn460.lib
opencv_dnn_objdetect460.lib
opencv_dnn_superres460.lib
opencv_dpm460.lib
opencv_face460.lib
opencv_features2d460.lib
opencv_flann460.lib
opencv_fuzzy460.lib
opencv_gapi460.lib
opencv_hfs460.lib
opencv_highgui460.lib
opencv_imgcodecs460.lib
opencv_imgproc460.lib
opencv_img_hash460.lib
opencv_intensity_transform460.lib
opencv_line_descriptor460.lib
opencv_mcc460.lib
opencv_ml460.lib
opencv_objdetect460.lib
opencv_optflow460.lib
opencv_phase_unwrapping460.lib
opencv_photo460.lib
opencv_plot460.lib
opencv_quality460.lib
opencv_rapid460.lib
opencv_reg460.lib
opencv_rgbd460.lib
opencv_saliency460.lib
opencv_shape460.lib
opencv_stereo460.lib
opencv_stitching460.lib
opencv_structured_light460.lib
opencv_superres460.lib
opencv_surface_matching460.lib
opencv_text460.lib
opencv_tracking460.lib
opencv_video460.lib
opencv_videoio460.lib
opencv_videostab460.lib
opencv_wechat_qrcode460.lib
opencv_xfeatures2d460.lib
opencv_ximgproc460.lib
opencv_xobjdetect460.lib
opencv_xphoto460.lib

系統環境變數設定

Path

D:\Libraries\opencv\opencv\build\install\x64\vc17\bin

留言版

發表留言