OpenCV定制源码编译

1. cmake选项

  • 测试单元可以关掉:BUILD_DOCS,BUILD_EXAMPLES,BUILD_XXX_TESTS,BUILD_opencv_ts(一些单元测试代码),BUILD_PACKAGE (CPACK_BINARY_XXX,CPACK_SOURCE_XXX),INSTALL_XXX
  • 减少引入体积:打开世界模块开关BUILD_opencv_world(暂时没开,因为编译之后发现找不到要引用的头文件了),打开BUILD_SHARED_LIBS
  • 关掉音视频处理相关模块:BUILD_opencv_video,BUILD_opencv_videoio,BUILD_opencv_videostab,WITH_1394,WITH_GSTREAMER_XXX
  • 关闭GPU相关模块:WITH_OPENCL,WITH_CUDA
  • 打开TBB模块:隐式的并行计算程序,底层依赖于操作系统的多线程库,BUILD_TBB
  • 打开viz模块:WITH_VTK,BUILD_opencv_viz
  • 暂时没开启Java相关模块:ant,就没brew过这个包

以上reference from 博客1博客2

2. extra modules

with opencv3.0, SURF/SIFT and some other things have been moved to a seperate opencv_contrib repo.

一部分模块被独立到了opencv_contrib这个包,首先clone到本地,然后在cmake选项里面找到OPENCV_EXTRA_MODULES_PATH,填好。

2. 其他说明

另外之前brew install的opencv包一定要卸载掉,不要乱link,否则INCLUDE和LIBS的路径都会出问题,手动修改cmake文件不要太酸爽。