LINUX/CMAKE编译opencv_contrib

实际上编译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
相关推荐
朝九晚五ฺ2 分钟前
【Linux探索学习】第十四弹——进程优先级:深入理解操作系统中的进程优先级
linux·运维·学习
自由的dream6 分钟前
Linux的桌面
linux
xiaozhiwise36 分钟前
Makefile 之 自动化变量
linux
前端李易安2 小时前
Webpack 热更新(HMR)详解:原理与实现
前端·webpack·node.js
如若1232 小时前
主要用于图像的颜色提取、替换以及区域修改
人工智能·opencv·计算机视觉
意疏3 小时前
【Linux 篇】Docker 的容器之海与镜像之岛:于 Linux 系统内探索容器化的奇妙航行
linux·docker
BLEACH-heiqiyihu3 小时前
RedHat7—Linux中kickstart自动安装脚本制作
linux·运维·服务器
一只爱撸猫的程序猿3 小时前
一个简单的Linux 服务器性能优化案例
linux·mysql·nginx
loey_ln3 小时前
webpack配置和打包性能优化
前端·webpack·性能优化