Ubuntu20.04中怎么编译安装OpenCV4.3
今天就跟大家聊聊有关Ubuntu 20.04中怎么编译安装OpenCV 4.3,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。
创新互联是一家专业提供泰安企业网站建设,专注与成都网站制作、成都做网站、H5建站、小程序制作等业务。10年已为泰安众多企业、政府机构等服务。创新互联专业网站设计公司优惠进行中。
1、安装依赖
sudo apt install build-essential cmake git pkg-config libgtk-3-dev \ libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \ libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \ gfortran openexr libatlas-base-dev python3-dev python3-numpy \ libtbb2 libtbb-dev libdc1394-22-dev libopenexr-dev \ libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev \ qtbase5-dev qtdeclarative5-dev llvm clang libclang-dev
2、下载OpenCV 4.3源码
OpenCV: https://github.com/opencv/opencv/releases/tag/4.3.0
OpenCV contrib: https://github.com/opencv/opencv_contrib/releases/tag/4.3.0
1)下载地址:
https://github.com/opencv/opencv/archive/refs/tags/4.3.0.tar.gz
https://github.com/opencv/opencv_contrib/archive/refs/tags/4.3.0.tar.gz
2)解压到目录:/home/admin/opencv_4.3_build/
cd /home/admin/opencv_4.3_build/ tar -zxvf opencv-4.3.0.tar.gz tar -zxvf opencv_contrib-4.3.0.tar.gz
3、Configure
cd /home/admin/opencv_4.3_build/opencv-4.3.0/ cmake .. \ -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=/usr/local \ -D WITH_TBB=ON \ -D WITH_V4L=ON \ -D WITH_QT=ON \ -D WITH_GTK=ON \ -D WITH_OPENGL=ON \ -D WITH_VTK=ON \ -D OPENCV_GENERATE_PKGCONFIG=YES \ -D INSTALL_C_EXAMPLES=ON \ -D INSTALL_PYTHON_EXAMPLES=ON \ -D OPENCV_GENERATE_PKGCONFIG=ON \ -D OPENCV_ENABLE_NONFREE=ON \ -D BUILD_DOCS=ON \ -D BUILD_EXAMPLES=ON \ -D PYTHON3_EXECUTABLE=/usr/bin/python3 \ -D PYTHON_INCLUDE_DIR=/usr/include/python3.8 \ -D PYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.8.so \ -D OPENCV_EXTRA_MODULES_PATH=/home/admin/opencv_4.3_build/opencv-4.3.0/opencv_contrib-4.3.0/modules \ -D BUILD_EXAMPLES=ON
4、Build
(-j后面的数字代表多线程,请根据自己的电脑配置设置,官网默认为7)
make -j12
5、Install
sudo make install
6、验证安装
pkg-config --modversion opencv4 # 输出:4.3.0 python3 -c "import cv2; print(cv2.__version__)" # 输出:4.3.0
看完上述内容,你们对Ubuntu 20.04中怎么编译安装OpenCV 4.3有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注创新互联行业资讯频道,感谢大家的支持。
新闻标题:Ubuntu20.04中怎么编译安装OpenCV4.3
URL分享:http://azwzsj.com/article/pdjpgg.html