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
相关推荐
林农8 分钟前
C02S10-Linux的进程和计划任务管理
linux·云计算
188_djh1 小时前
# vim那些事...... vim删除文件全部内容
linux·ubuntu·centos·编辑器·vim·vi·vim删除文件全部内容
小安运维日记2 小时前
Linux云计算 |【第五阶段】PROJECT3-DAY1
linux·运维·安全·云计算
火车叼位3 小时前
Linux Bash任务管理命令详解
linux
时光话3 小时前
第二节 管道符、重定向与环境变量
linux
johnny_hhh5 小时前
在Rocky Linux 9上部署NFS服务并对其进行权限配额管理以及监控
linux·运维·服务器
╰⋛⋋⊱⋋翅膀⋌⊰⋌⋚╯5 小时前
linux-下载抖音作品
linux
前端李易安5 小时前
webpack的常见配置
前端·webpack·node.js