opencv非常龐大,有很多模塊,但大部分情況我們可能只會用到三四個模塊,此時如果還是直接cmake . & make,將會非常費時,尤其是部署時很麻煩。
所以需要去除掉一些不需要的模塊,可參考如下編譯腳本,build_opencv.sh :
#!/bin/sh cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D BUILD_opencv_gpu=OFF \ -D BUILD_DOCS=OFF \ -D BUILD_PERF_TESTS=OFF \ -D BUILD_TESTS=OFF \ -D BUILD_WITH_DEBUG_INFO=OFF \ -D BUILD_opencv_apps=OFF \ -D BUILD_opencv_calib3d=OFF \ -D BUILD_opencv_contrib=OFF \ -D BUILD_opencv_features2d=OFF \ -D BUILD_opencv_flann=OFF \ -D BUILD_opencv_gpu=OFF \ -D BUILD_opencv_ml=OFF \ -D BUILD_opencv_nonfree=OFF \ -D BUILD_opencv_objdetect=OFF \ -D BUILD_opencv_photo=OFF \ -D BUILD_opencv_stitching=OFF \ -D BUILD_opencv_superres=OFF \ -D BUILD_opencv_ts=OFF \ -D BUILD_opencv_video=OFF \ -D BUILD_opencv_videostab=OFF \ . make sudo make install
