ubuntu 编译opencv4.2 + opencv_contrib

ubuntu 编译opencv4.2

请查看ubuntu 编译opencv4.2 for java ,不配置java环境即可。

下载opencv_contrib包

git clone https://github.com/opencv/opencv_contrib.git

开始安装

mkdir build && cd build && mkdir install
cmake -D CMAKE_INSTALL_PREFIX=./install -D CMAKE_BUILD_TYPE=Release -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_SHARED_LIBS=OFF -D WITH_OPENMP=ON -D ENABLE_PRECOMPILED_HEADERS=OFF ..

如果看到下面信息,则为cmake成功

-- 
-- Configuring done
-- Generating done
-- Build files have been written to: 此处省略/opencv4.2.0/build

然后先别着急,往上面翻查看以下信息:

...
--   OpenCV modules:
--     To be built:                 aruco bgsegm bioinspired calib3d ccalib core datasets dnn dnn_objdetect dnn_superres dpm face features2d flann freetype fuzzy gapi hdf hfs highgui img_hash imgcodecs imgproc intensity_transform java line_descriptor ml objdetect optflow phase_unwrapping photo plot python2 quality rapid reg rgbd saliency shape stereo stitching structured_light superres surface_matching text tracking ts video videoio videostab xfeatures2d ximgproc xobjdetect xphoto
--     Disabled:                    world
--     Disabled by dependency:      -
--     Unavailable:                 alphamat cnn_3dobj cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev cvv js matlab ovis python3 sfm viz xfeatures2d
--     Applications:                tests perf_tests apps
--     Documentation:               NO
--     Non-free algorithms:         NO

其中To be built: 一栏中比之前多了很多,这就对了。

make -j8

等待… (该过程非常慢,耐心等,大概需要30-60分钟)

编译成功即可。
如有必要,执行 make install
如果出现 提示opencv_contrib缺少boostdesc_bgm.i等文件,请查看编译OpenCV提示opencv_contrib缺少boostdesc_bgm.i等文件

参考: https://www.cnblogs.com/fx-blog/p/8213704.html

你可能感兴趣的:(opencv)