常用配置:
WITH_OPENGL=ON
DBUILD_opencv_rgbd=OFF #此項需要關閉,不然編譯opencv_contrib時會報錯
OPENCV_GENERATE_SETUPVARS=OFF
OPENCV_EXTRA_MODULES_PATH=your path #這里填寫opencv_contrib/modules的路徑
編譯時報錯:
[ 43%] Building RC object modules/core/CMakeFiles/opencv_core.dir/vs_version.rc.obj
gcc: error: long: No such file or directory
C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin\windres.exe: preprocessing failed.
mingw32-make[2]: *** [modules\core\CMakeFiles\opencv_core.dir\build.make:1265: modules/core/CMakeFiles/opencv_core.dir/vs_version.rc.obj] Error 1
mingw32-make[2]: *** Waiting for unfinished jobs....
mingw32-make[1]: *** [CMakeFiles\Makefile2:3666: modules/core/CMakeFiles/opencv_core.dir/all] Error 2
mingw32-make: *** [Makefile:162: all] Error 2
需要額外添加兩條配置
DOPENCV_SKIP_LIBATOMIC_COMPILER_CHECK=ON
DOPENCV_ALLOCATOR_STATS_COUNTER_TYPE=int64_t
OPENCV_ENABLE_ALLOCATOR_STATS=OFF