今天就跟大家聊聊有关Ubuntu 20.04中怎么编译安装OpenCV 4.3,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。
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
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
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
(-j后面的数字代表多线程,请根据自己的电脑配置设置,官网默认为7)
make -j12
sudo make install
pkg-config --modversion opencv4 # 输出:4.3.0 python3 -c "import cv2; print(cv2.__version__)" # 输出:4.3.0
看完上述内容,你们对Ubuntu 20.04中怎么编译安装OpenCV 4.3有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注亿速云行业资讯频道,感谢大家的支持。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。