实际上编译OpenCV时,连带编译opencv_contrib。
-
编译脚本
OPENCV_VERSION=4.10.0
OPENCV_DIR=opencv-{OPENCV_VERSION} OPENCV_CONTRIB_DIR=opencv_contrib-{OPENCV_VERSION}BUILD_DIR=
pwd
cd {BUILD_DIR}/{OPENCV_DIR}mkdir build
cd build/
cmake
-D CMAKE_BUILD_TYPE=RELEASE
-D CMAKE_INSTALL_PREFIX=/usr/local
-DENABLE_PRECOMPILED_HEADERS=OFF
-D OPENCV_EXTRA_MODULES_PATH={BUILD_DIR}/{OPENCV_CONTRIB_DIR}/modules
..sudo make -j16
sudo make install
-
去掉不想编译的模块
如果不想编译modules下某个模块,可以关掉。以下是关掉所有模块:
OPENCV_VERSION=4.10.0
OPENCV_DIR=opencv-${OPENCV_VERSION}
OPENCV_CONTRIB_DIR=opencv_contrib-${OPENCV_VERSION}
BUILD_DIR=`pwd`
cd ${BUILD_DIR}/${OPENCV_DIR}
mkdir build
cd build/
cmake \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-DENABLE_PRECOMPILED_HEADERS=OFF \
-D OPENCV_EXTRA_MODULES_PATH=${BUILD_DIR}/${OPENCV_CONTRIB_DIR}/modules \
-D BUILD_opencv_alphamat=OFF \
-D BUILD_opencv_aruco=OFF \
-D BUILD_opencv_bgsegm=OFF \
-D BUILD_opencv_bioinspired=OFF \
-D BUILD_opencv_ccalib=OFF \
-D BUILD_opencv_cnn_3dobj=OFF \
-D BUILD_opencv_cvv=OFF \
-D BUILD_opencv_datasets=OFF \
-D BUILD_opencv_dnn_objdetect=OFF \
-D BUILD_opencv_dnn_superres=OFF \
-D BUILD_opencv_dnns_easily_fooled=OFF \
-D BUILD_opencv_dpm=OFF \
-D BUILD_opencv_face=OFF \
-D BUILD_opencv_freetype=OFF \
-D BUILD_opencv_fuzzy=OFF \
-D BUILD_opencv_hdf=OFF \
-D BUILD_opencv_hfs=OFF \
-D BUILD_opencv_img_hash=OFF \
-D BUILD_opencv_intensity_transform=OFF \
-D BUILD_opencv_julia=OFF \
-D BUILD_opencv_line_descriptor=OFF \
-D BUILD_opencv_matlab=OFF \
-D BUILD_opencv_mcc=OFF \
-D BUILD_opencv_optflow=OFF \
-D BUILD_opencv_ovis=OFF \
-D BUILD_opencv_phase_unwrapping=OFF \
-D BUILD_opencv_plot=OFF \
-D BUILD_opencv_quality=OFF \
-D BUILD_opencv_rapid=OFF \
-D BUILD_opencv_reg=OFF \
-D BUILD_opencv_rgbd=OFF \
-D BUILD_opencv_saliency=OFF \
-D BUILD_opencv_signal=OFF \
-D BUILD_opencv_sfm=OFF \
-D BUILD_opencv_shape=OFF \
-D BUILD_opencv_stereo=OFF \
-D BUILD_opencv_structured_light=OFF \
-D BUILD_opencv_superres=OFF \
-D BUILD_opencv_surface_matching=OFF \
-D BUILD_opencv_text=OFF \
-D BUILD_opencv_tracking=OFF \
-D BUILD_opencv_videostab=OFF \
-D BUILD_opencv_viz=OFF \
-D BUILD_opencv_wechat_qrcode=OFF \
-D BUILD_opencv_xfeatures2d=OFF \
-D BUILD_opencv_ximgproc=OFF \
-D BUILD_opencv_xobjdetect=OFF \
-D BUILD_opencv_xphoto=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D OPENCV_GENERATE_PKGCONFIG=OFF \
-D BUILD_EXAMPLES=OFF \
..
sudo make -j16
sudo make install