ubuntu编译opencv
欢迎转载,请支持原创,保留原文链接:blog.ilibrary.me
ubuntu下面编译opencv, 有坑,记录一下.
根据官方教程编译,坑少一点。
- 教程地址: https://docs.opencv.org/4.x/d7/d9f/tutorial_linux_install.html
- 下载opencv: wget -O opencv.zip https://github.com/opencv/opencv/archive/4.x.zip
- 下载扩展包, opencv contrib: wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/4.x.zip
- 解压并配置目录:
unzip opencv.zip unzip opencv_contrib.zip # Create build directory and switch into it mkdir -p build && cd build
- 配置:
cmake -DOPENCV_EXTRA_MODULES_PATH=../opencv_contrib-4.5.5/modules -D BUILD_opencv_python=OFF -D OPENCV_ENABLE_NONFREE=ON ../opencv-4.5.5
- DOPENCV_EXTRA_MODULES_PATH, 编译扩展包。没有扩展包很多功能用不了。
- BUILD_opencv_python=OFF, 关闭python extension. 在ubuntu下python extension总是编译不过。先跳过。
- OPENCV_ENABLE_NONFREE=ON, 下载编译专利算法包。要不然surf算法用不了。
- 编译:
make -j8
, 8线程编译. - 安装:
sudo make install