ubuntu安装opencv教程
想要在 Ubuntu 上搭建 OpenCV 环境?别担心,这篇文章手把手教你完成!??
开门见山说,打开终端(Terminal),确保体系是最新的:
“`bash
sudo apt update && sudo apt upgrade -y
“`
接着,安装必要的依赖项:
“`bash
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
“`
接着,克隆 OpenCV 源码:
“`bash
cd ~
git clone https://github.com/opencv/opencv.git
cd opencv
mkdir build
cd build
“`
运行 CMake 配置:
“`bash
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_OPENGL=ON ..
“`
最终,编译并安装:
“`bash
make -j$(nproc)
sudo make install
“`
?? 完成啦!通过这些步骤,你的 Ubuntu 体系已经成功安装了 OpenCV4!??
记得检查版本是否正确:
“`bash
pkg-config –modversion opencv4
“`
快去试试吧!??